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
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
|
/* SPDX-License-Identifier: GPL-2.0 */
/*
* Copyright (c) Samsung Electronics Co., Ltd.
* Author: Minwoo Kim <minwoo7945.kim@samsung.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation.
*/
#ifndef __PANEL_DRV_H__
#define __PANEL_DRV_H__
#include <linux/device.h>
#include <linux/fb.h>
#include <linux/notifier.h>
#include <linux/kernel.h>
#include <linux/regulator/consumer.h>
#include <linux/delay.h>
#include <linux/io.h>
#include <media/v4l2-subdev.h>
#include <linux/workqueue.h>
#include <linux/miscdevice.h>
#if defined(CONFIG_EXYNOS_DPU20)
#include "../dpu20/disp_err.h"
#include "../dpu20/dsim.h"
#include "../dpu20/decon.h"
#include "../dpu20/panels/decon_lcd.h"
#else
#include "../dpu_9810/disp_err.h"
#include "../dpu_9810/dsim.h"
#include "../dpu_9810/decon.h"
#include "../dpu_9810/panels/decon_lcd.h"
#endif
#include "panel.h"
#include "mdnie.h"
#include "copr.h"
#ifdef CONFIG_SUPPORT_DDI_FLASH
#include "panel_poc.h"
#endif
#ifdef CONFIG_ACTIVE_CLOCK
#include "active_clock.h"
#endif
#ifdef CONFIG_EXTEND_LIVE_CLOCK
#include "./aod/aod_drv.h"
#endif
#ifdef CONFIG_SUPPORT_DISPLAY_PROFILER
#include "./display_profiler/display_profiler.h"
#endif
#ifdef CONFIG_SUPPORT_POC_SPI
#include "panel_spi.h"
#endif
#if defined(CONFIG_TDMB_NOTIFIER)
#include <linux/tdmb_notifier.h>
#endif
extern int panel_log_level;
#define CONFIG_DISP_PMIC_SSD
void clear_pending_bit(int irq);
#define panel_err(fmt, ...) \
do { \
if (panel_log_level >= 3) { \
pr_err(pr_fmt(fmt), ##__VA_ARGS__); \
} \
} while (0)
#define panel_warn(fmt, ...) \
do { \
if (panel_log_level >= 4) { \
pr_warn(pr_fmt(fmt), ##__VA_ARGS__); \
} \
} while (0)
#define panel_info(fmt, ...) \
do { \
if (panel_log_level >= 6) \
pr_info(pr_fmt(fmt), ##__VA_ARGS__); \
} while (0)
#define panel_dbg(fmt, ...) \
do { \
if (panel_log_level >= 6) \
pr_info(pr_fmt(fmt), ##__VA_ARGS__); \
} while (0)
enum {
PANEL_REGULATOR_TYPE_PWR = 0,
PANEL_REGULATOR_TYPE_SSD = 1,
PANEL_REGULATOR_TYPE_MAX,
};
enum {
PANEL_REGULATOR_DDI_3P0 = 0,
PANEL_REGULATOR_DDI_1P8,
PANEL_REGULATOR_DDR_1P6,
PANEL_REGULATOR_SSD,
PANEL_REGULATOR_MAX
};
enum panel_gpio_lists {
PANEL_GPIO_RESET = 0,
PANEL_GPIO_DISP_DET,
PANEL_GPIO_PCD,
PANEL_GPIO_ERR_FG,
PANEL_GPIO_CONN_DET,
PANEL_GPIO_MAX,
};
#define PANEL_GPIO_NAME_RESET ("disp-reset")
#define PANEL_GPIO_NAME_DISP_DET ("disp-det")
#define PANEL_GPIO_NAME_PCD ("pcd")
#define PANEL_GPIO_NAME_ERR_FG ("err-fg")
#define PANEL_GPIO_NAME_CONN_DET ("conn-det")
#define PANEL_REGULATOR_NAME_DDI_3P0 ("ddi-3p0")
#define PANEL_REGULATOR_NAME_DDI_1P8 ("ddi-1p8")
#define PANEL_REGULATOR_NAME_DDR_1P6 ("ddr-1p6")
#define PANEL_REGULATOR_NAME_SSD ("short-detect")
struct panel_gpio {
const char *name;
int num;
bool active_low;
int dir; /* 0:out, 1:in */
int irq;
unsigned int irq_type;
void __iomem *irq_pend_reg;
int irq_pend_bit;
};
struct panel_regulator {
const char *name;
struct regulator *reg;
int type;
int def_voltage;
int lpm_voltage;
int def_current;
int lpm_current;
};
#define DSIM_OPTION_WAIT_TX_DONE (1U << 0)
#define DSIM_OPTION_POINT_GPARA (1U << 1)
struct mipi_drv_ops {
int (*read)(u32 id, u8 addr, u8 ofs, u8 *buf, int size, u32 option);
int (*write)(u32 id, u8 cmd_id, const u8 *cmd, u8 ofs, int size, u32 option, bool wakeup);
enum dsim_state(*get_state)(u32 id);
void (*parse_dt)(struct device_node *node, struct decon_lcd *lcd_info);
};
#define PANEL_INIT_KERNEL 0
#define PANEL_INIT_BOOT 1
#define PANEL_DISP_DET_HIGH 1
#define PANEL_DISP_DET_LOW 0
enum {
PANEL_STATE_NOK = 0,
PANEL_STATE_OK = 1,
};
enum {
PANEL_EL_OFF = 0,
PANEL_EL_ON = 1,
};
enum {
PANEL_UB_CONNECTED = 0,
PANEL_UB_DISCONNECTED = 1,
};
enum {
PANEL_DISCONNECT = 0,
PANEL_CONNECT = 1,
};
#define ALPM_MODE 0
#define HLPM_MODE 1
enum panel_active_state {
PANEL_STATE_OFF = 0,
PANEL_STATE_ON,
PANEL_STATE_NORMAL,
PANEL_STATE_ALPM,
};
enum panel_power {
PANEL_POWER_OFF = 0,
PANEL_POWER_ON
};
enum {
PANEL_DISPLAY_OFF = 0,
PANEL_DISPLAY_ON,
};
enum {
PANEL_HMD_OFF = 0,
PANEL_HMD_ON,
};
enum {
PANEL_WORK_DISP_DET = 0,
PANEL_WORK_PCD,
PANEL_WORK_ERR_FG,
PANEL_WORK_CONN_DET,
PANEL_WORK_DIM_FLASH,
PANEL_WORK_CHECK_CONDITION,
PANEL_WORK_MAX,
};
struct panel_state {
int init_at;
int connect_panel;
int connected;
int cur_state;
int power;
int disp_on;
#ifdef CONFIG_SUPPORT_HMD
int hmd_on;
#endif
int lpm_brightness;
};
struct copr_spi_gpios {
int gpio_sck;
int gpio_miso;
int gpio_mosi;
int gpio_cs;
};
struct host_cb {
int (*cb)(void *data);
void *data;
};
enum {
NO_CHECK_STATE = 0,
PRINT_NORMAL_PANEL_INFO,
CHECK_NORMAL_PANEL_INFO,
PRINT_DOZE_PANEL_INFO,
STATE_MAX
};
#define STR_NO_CHECK ("no state")
#define STR_NOMARL_ON ("after normal disp on")
#define STR_NOMARL_100FRAME ("check normal in 100frames")
#define STR_AOD_ON ("after aod disp on")
struct panel_condition_check {
bool is_panel_check;
u32 frame_cnt;
u8 check_state;
char str_state[STATE_MAX][30];
};
enum GAMMA_FLASH_RESULT {
GAMMA_FLASH_ERROR_MTP_OFFSET = -4,
GAMMA_FLASH_ERROR_CHECKSUM_MISMATCH = -3,
GAMMA_FLASH_ERROR_NOT_EXIST = -2,
GAMMA_FLASH_ERROR_READ_FAIL = -1,
GAMMA_FLASH_PROGRESS = 0,
GAMMA_FLASH_SUCCESS = 1,
};
struct dim_flash_result {
u8 mtp_reg[34];
u8 mtp_flash[34];
bool exist;
u32 dim_chksum_ok;
u32 dim_chksum_by_calc;
u32 dim_chksum_by_read;
u32 mtp_chksum_ok;
u32 mtp_chksum_by_calc;
u32 mtp_chksum_by_read;
};
typedef void (*panel_wq_handler)(struct work_struct *);
struct panel_work {
struct mutex lock;
struct workqueue_struct *wq;
struct delayed_work dwork;
atomic_t running;
void *data;
int ret;
};
#ifdef CONFIG_DYNAMIC_FREQ
#define MAX_DYNAMIC_FREQ 5
#define DF_CONTEXT_RIL 1
#endif
struct panel_device {
int id;
int dsi_id;
struct device_node *ddi_node;
struct spi_device *spi;
struct copr_info copr;
struct copr_spi_gpios spi_gpio;
/* mutex lock for panel operations */
struct mutex op_lock;
/* mutex lock for panel's data */
struct mutex data_lock;
/* mutex lock for panel's ioctl */
struct mutex io_lock;
struct device *dev;
struct mdnie_info mdnie;
struct lcd_device *lcd;
struct panel_bl_device panel_bl;
unsigned char panel_id[3];
struct v4l2_subdev sd;
struct panel_gpio gpio[PANEL_GPIO_MAX];
struct panel_regulator regulator[PANEL_REGULATOR_MAX];
struct decon_lcd lcd_info;
struct mipi_drv_ops mipi_drv;
struct panel_state state;
struct panel_work work[PANEL_WORK_MAX];
struct notifier_block fb_notif;
#ifdef CONFIG_DISPLAY_USE_INFO
struct notifier_block panel_dpui_notif;
#endif
struct panel_info panel_data;
#ifdef CONFIG_ACTIVE_CLOCK
struct act_clock_dev act_clk_dev;
#endif
#ifdef CONFIG_EXTEND_LIVE_CLOCK
struct aod_dev_info aod;
#endif
#ifdef CONFIG_SUPPORT_DDI_FLASH
struct panel_poc_device poc_dev;
#endif
#ifdef CONFIG_SUPPORT_POC_SPI
struct panel_spi_dev panel_spi_dev;
#endif
#ifdef CONFIG_SUPPORT_TDMB_TUNE
struct notifier_block tdmb_notif;
#endif
struct disp_error_cb_info error_cb_info;
ktime_t ktime_panel_on;
ktime_t ktime_panel_off;
#ifdef CONFIG_SUPPORT_DIM_FLASH
struct dim_flash_result dim_flash_result;
struct panel_irc_info *irc_info;
#endif
struct panel_condition_check condition_check;
#ifdef CONFIG_EXYNOS_ADAPTIVE_FREQ
struct adaptive_idx adap_idx;
#endif
#ifdef CONFIG_DYNAMIC_FREQ
struct notifier_block df_noti;
struct df_status_info df_status;
struct df_freq_tbl_info *df_freq_tbl;
#endif
#ifdef CONFIG_SUPPORT_DISPLAY_PROFILER
struct profiler_device profiler;
#endif
};
#ifdef CONFIG_SUPPORT_DIM_FLASH
int panel_update_dim_type(struct panel_device *panel, u32 dim_type);
#endif
static inline bool IS_PANEL_PWR_ON_STATE(struct panel_device *panel)
{
return (panel->state.cur_state == PANEL_STATE_ON ||
panel->state.cur_state == PANEL_STATE_NORMAL ||
panel->state.cur_state == PANEL_STATE_ALPM);
}
static inline bool IS_PANEL_PWR_OFF_STATE(struct panel_device *panel)
{
return panel->state.cur_state == PANEL_STATE_OFF;
}
int panel_display_on(struct panel_device *panel);
int __set_panel_power(struct panel_device *panel, int power);
#ifdef CONFIG_EXTEND_LIVE_CLOCK
static inline int panel_aod_init_panel(struct panel_device *panel)
{
return (panel->aod.ops && panel->aod.ops->init_panel) ?
panel->aod.ops->init_panel(&panel->aod) : 0;
}
static inline int panel_aod_enter_to_lpm(struct panel_device *panel)
{
return (panel->aod.ops && panel->aod.ops->enter_to_lpm) ?
panel->aod.ops->enter_to_lpm(&panel->aod) : 0;
}
static inline int panel_aod_exit_from_lpm(struct panel_device *panel)
{
return (panel->aod.ops && panel->aod.ops->exit_from_lpm) ?
panel->aod.ops->exit_from_lpm(&panel->aod) : 0;
}
static inline int panel_aod_doze_suspend(struct panel_device *panel)
{
return (panel->aod.ops && panel->aod.ops->doze_suspend) ?
panel->aod.ops->doze_suspend(&panel->aod) : 0;
}
static inline int panel_aod_power_off(struct panel_device *panel)
{
return (panel->aod.ops && panel->aod.ops->power_off) ?
panel->aod.ops->power_off(&panel->aod) : 0;
}
#ifdef SUPPORT_NORMAL_SELF_MOVE
static inline int panel_self_move_pattern_update(struct panel_device *panel)
{
return (panel->aod.ops && panel->aod.ops->self_move_pattern_update) ?
panel->aod.ops->self_move_pattern_update(&panel->aod) : 0;
}
#endif
#endif
bool ub_con_disconnected(struct panel_device *panel);
int panel_wake_lock(struct panel_device *panel);
void panel_wake_unlock(struct panel_device *panel);
bool panel_gpio_valid(struct panel_gpio *gpio);
void panel_send_ubconn_uevent(struct panel_device *panel);
#define PANEL_DRV_NAME "panel-drv"
#define PANEL_IOC_BASE 'P'
#define PANEL_IOC_DSIM_PROBE _IOW(PANEL_IOC_BASE, 1, struct decon_lcd *)
#define PANEL_IOC_GET_PANEL_STATE _IOW(PANEL_IOC_BASE, 3, struct panel_state *)
#define PANEL_IOC_DSIM_PUT_MIPI_OPS _IOR(PANEL_IOC_BASE, 4, struct mipi_ops *)
#define PANEL_IOC_PANEL_PROBE _IO(PANEL_IOC_BASE, 5)
#define PANEL_IOC_SET_POWER _IO(PANEL_IOC_BASE, 6)
#define PANEL_IOC_SLEEP_IN _IO(PANEL_IOC_BASE, 7)
#define PANEL_IOC_SLEEP_OUT _IO(PANEL_IOC_BASE, 8)
#define PANEL_IOC_DISP_ON _IO(PANEL_IOC_BASE, 9)
#define PANEL_IOC_PANEL_DUMP _IO(PANEL_IOC_BASE, 10)
#define PANEL_IOC_EVT_FRAME_DONE _IOW(PANEL_IOC_BASE, 11, struct timespec *)
#define PANEL_IOC_EVT_VSYNC _IOW(PANEL_IOC_BASE, 12, struct timespec *)
#ifdef CONFIG_SUPPORT_DOZE
#define PANEL_IOC_DOZE _IO(PANEL_IOC_BASE, 31)
#define PANEL_IOC_DOZE_SUSPEND _IO(PANEL_IOC_BASE, 32)
#endif
#ifdef CONFIG_SUPPORT_DSU
#ifdef CONFIG_EXYNOS_MULTIRESOLUTION
#define PANEL_IOC_SET_DSU _IOW(PANEL_IOC_BASE, 41, int *)
#else
#define PANEL_IOC_SET_DSU _IOW(PANEL_IOC_BASE, 41, struct dsu_info *)
#endif
#endif
#define PANEL_IOC_REG_RESET_CB _IOR(PANEL_IOC_BASE, 51, struct host_cb *)
#ifdef CONFIG_SUPPORT_INDISPLAY
#define PANEL_IOC_SET_FINGER_SET _IO(PANEL_IOC_BASE, 61)
#endif
#ifdef CONFIG_EXYNOS_ADAPTIVE_FREQ
#define PANEL_IOC_MIPI_FREQ_CHANGED _IOR(PANEL_IOC_BASE, 71, int *)
#endif
#ifdef CONFIG_DYNAMIC_FREQ
#define MAGIC_DF_UPDATED (0x0A55AA55)
#define PANEL_IOC_GET_DF_STATUS _IOR(PANEL_IOC_BASE, 85, int *)
#define PANEL_IOC_DYN_FREQ_FFC _IOR(PANEL_IOC_BASE, 82, int *)
#endif
#endif //__PANEL_DRV_H__
|