12fe4e5f8Sopenharmony_ci/* 22fe4e5f8Sopenharmony_ci * Copyright (c) 2022 Huawei Device Co., Ltd. 32fe4e5f8Sopenharmony_ci * 42fe4e5f8Sopenharmony_ci * This program is free software; you can redistribute it and/or 52fe4e5f8Sopenharmony_ci * modify it under the terms of the GNU General Public License 62fe4e5f8Sopenharmony_ci * as published by the Free Software Foundation; either version 2 72fe4e5f8Sopenharmony_ci * of the License, or (at your option) any later version. 82fe4e5f8Sopenharmony_ci * 92fe4e5f8Sopenharmony_ci * This program is distributed in the hope that it will be useful, 102fe4e5f8Sopenharmony_ci * but WITHOUT ANY WARRANTY; without even the implied warranty of 112fe4e5f8Sopenharmony_ci * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 122fe4e5f8Sopenharmony_ci * GNU General Public License for more details. 132fe4e5f8Sopenharmony_ci * 142fe4e5f8Sopenharmony_ci * You should have received a copy of the GNU General Public License 152fe4e5f8Sopenharmony_ci * along with this program; if not, write to the Free Software 162fe4e5f8Sopenharmony_ci * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 172fe4e5f8Sopenharmony_ci */ 182fe4e5f8Sopenharmony_ci 192fe4e5f8Sopenharmony_ci#include "gpio_if.h" 202fe4e5f8Sopenharmony_ci#include "hdf_bl.h" 212fe4e5f8Sopenharmony_ci#include "hdf_disp.h" 222fe4e5f8Sopenharmony_ci#include "hdf_log.h" 232fe4e5f8Sopenharmony_ci#include "mipi_dsi_if.h" 242fe4e5f8Sopenharmony_ci#include "osal.h" 252fe4e5f8Sopenharmony_ci#include "pwm_if.h" 262fe4e5f8Sopenharmony_ci 272fe4e5f8Sopenharmony_ci#define RESET_GPIO 5 282fe4e5f8Sopenharmony_ci#define MIPI_DSI0 0 292fe4e5f8Sopenharmony_ci#define BLK_PWM1 1 302fe4e5f8Sopenharmony_ci#define PWM_MAX_PERIOD 100000 312fe4e5f8Sopenharmony_ci/* backlight setting */ 322fe4e5f8Sopenharmony_ci#define MIN_LEVEL 0 332fe4e5f8Sopenharmony_ci#define MAX_LEVEL 255 342fe4e5f8Sopenharmony_ci#define DEFAULT_LEVEL 100 352fe4e5f8Sopenharmony_ci 362fe4e5f8Sopenharmony_ci#define WIDTH 480 372fe4e5f8Sopenharmony_ci#define HEIGHT 960 382fe4e5f8Sopenharmony_ci#define HORIZONTAL_BACK_PORCH 20 392fe4e5f8Sopenharmony_ci#define HORIZONTAL_FRONT_PORCH 20 402fe4e5f8Sopenharmony_ci#define HORIZONTAL_SYNC_WIDTH 10 412fe4e5f8Sopenharmony_ci#define VERTICAL_BACK_PORCH 14 422fe4e5f8Sopenharmony_ci#define VERTICAL_FRONT_PORCH 16 432fe4e5f8Sopenharmony_ci#define VERTICAL_SYNC_WIDTH 2 442fe4e5f8Sopenharmony_ci#define FRAME_RATE 60 452fe4e5f8Sopenharmony_ci 462fe4e5f8Sopenharmony_ci#define WIDTH1 480 472fe4e5f8Sopenharmony_ci#define HEIGHT1 960 482fe4e5f8Sopenharmony_ci#define HORIZONTAL_BACK_PORCH1 44 492fe4e5f8Sopenharmony_ci#define HORIZONTAL_FRONT_PORCH1 46 502fe4e5f8Sopenharmony_ci#define HORIZONTAL_SYNC_WIDTH1 4 512fe4e5f8Sopenharmony_ci#define VERTICAL_BACK_PORCH1 15 522fe4e5f8Sopenharmony_ci#define VERTICAL_FRONT_PORCH1 15 532fe4e5f8Sopenharmony_ci#define VERTICAL_SYNC_WIDTH1 2 542fe4e5f8Sopenharmony_ci#define FRAME_RATE1 60 552fe4e5f8Sopenharmony_ci 562fe4e5f8Sopenharmony_ci/* panel0 on command payload */ 572fe4e5f8Sopenharmony_cistatic uint8_t g_payLoad0[] = { 0xF0, 0x5A, 0x5A }; 582fe4e5f8Sopenharmony_cistatic uint8_t g_payLoad1[] = { 0xF1, 0xA5, 0xA5 }; 592fe4e5f8Sopenharmony_cistatic uint8_t g_payLoad2[] = { 0xB3, 0x03, 0x03, 0x03, 0x07, 0x05, 0x0D, 0x0F, 0x11, 0x13, 0x09, 0x0B }; 602fe4e5f8Sopenharmony_cistatic uint8_t g_payLoad3[] = { 0xB4, 0x03, 0x03, 0x03, 0x06, 0x04, 0x0C, 0x0E, 0x10, 0x12, 0x08, 0x0A }; 612fe4e5f8Sopenharmony_cistatic uint8_t g_payLoad4[] = { 0xB0, 0x54, 0x32, 0x23, 0x45, 0x44, 0x44, 0x44, 0x44, 0x60, 0x00, 0x60, 0x1C }; 622fe4e5f8Sopenharmony_cistatic uint8_t g_payLoad5[] = { 0xB1, 0x32, 0x84, 0x02, 0x87, 0x12, 0x00, 0x50, 0x1C }; 632fe4e5f8Sopenharmony_cistatic uint8_t g_payLoad6[] = { 0xB2, 0x73, 0x09, 0x08 }; 642fe4e5f8Sopenharmony_cistatic uint8_t g_payLoad7[] = { 0xB6, 0x5C, 0x5C, 0x05 }; 652fe4e5f8Sopenharmony_cistatic uint8_t g_payLoad8[] = { 0xB8, 0x23, 0x41, 0x32, 0x30, 0x03 }; 662fe4e5f8Sopenharmony_cistatic uint8_t g_payLoad9[] = { 0xBC, 0xD2, 0x0E, 0x63, 0x63, 0x5A, 0x32, 0x22, 0x14, 0x22, 0x03 }; 672fe4e5f8Sopenharmony_cistatic uint8_t g_payLoad10[] = { 0xb7, 0x41 }; 682fe4e5f8Sopenharmony_cistatic uint8_t g_payLoad11[] = { 0xC1, 0x0c, 0x10, 0x04, 0x0c, 0x10, 0x04 }; 692fe4e5f8Sopenharmony_cistatic uint8_t g_payLoad12[] = { 0xC2, 0x10, 0xE0 }; 702fe4e5f8Sopenharmony_cistatic uint8_t g_payLoad13[] = { 0xC3, 0x22, 0x11 }; 712fe4e5f8Sopenharmony_cistatic uint8_t g_payLoad14[] = { 0xD0, 0x07, 0xFF }; 722fe4e5f8Sopenharmony_cistatic uint8_t g_payLoad15[] = { 0xD2, 0x63, 0x0B, 0x08, 0x88 }; 732fe4e5f8Sopenharmony_cistatic uint8_t g_payLoad16[] = { 0xC6, 0x08, 0x15, 0xFF, 0x10, 0x16, 0x80, 0x60 }; 742fe4e5f8Sopenharmony_cistatic uint8_t g_payLoad17[] = { 0xc7, 0x04 }; 752fe4e5f8Sopenharmony_cistatic uint8_t g_payLoad18[] = { 762fe4e5f8Sopenharmony_ci 0xC8, 0x7C, 0x50, 0x3B, 0x2C, 0x25, 0x16, 0x1C, 0x08, 0x27, 0x2B, 0x2F, 0x52, 0x43, 0x4C, 0x40, 772fe4e5f8Sopenharmony_ci 0x3D, 0x30, 0x1E, 0x06, 0x7C, 0x50, 0x3B, 0x2C, 0x25, 0x16, 0x1C, 0x08, 0x27, 0x2B, 0x2F, 0x52, 782fe4e5f8Sopenharmony_ci 0x43, 0x4C, 0x40, 0x3D, 0x30, 0x1E, 0x06 792fe4e5f8Sopenharmony_ci}; 802fe4e5f8Sopenharmony_cistatic uint8_t g_payLoad19[] = { 0x11 }; 812fe4e5f8Sopenharmony_cistatic uint8_t g_payLoad20[] = { 0x29 }; 822fe4e5f8Sopenharmony_ci 832fe4e5f8Sopenharmony_cistruct DsiCmdDesc g_OnCmd0[] = { 842fe4e5f8Sopenharmony_ci { 0x29, 0, sizeof(g_payLoad0), g_payLoad0 }, 852fe4e5f8Sopenharmony_ci { 0x29, 0, sizeof(g_payLoad1), g_payLoad1 }, 862fe4e5f8Sopenharmony_ci { 0x29, 0, sizeof(g_payLoad2), g_payLoad2 }, 872fe4e5f8Sopenharmony_ci { 0x29, 0, sizeof(g_payLoad3), g_payLoad3 }, 882fe4e5f8Sopenharmony_ci { 0x29, 0, sizeof(g_payLoad4), g_payLoad4 }, 892fe4e5f8Sopenharmony_ci { 0x29, 0, sizeof(g_payLoad5), g_payLoad5 }, 902fe4e5f8Sopenharmony_ci { 0x29, 0, sizeof(g_payLoad6), g_payLoad6 }, 912fe4e5f8Sopenharmony_ci { 0x29, 0, sizeof(g_payLoad7), g_payLoad7 }, 922fe4e5f8Sopenharmony_ci { 0x29, 0, sizeof(g_payLoad8), g_payLoad8 }, 932fe4e5f8Sopenharmony_ci { 0x29, 0, sizeof(g_payLoad9), g_payLoad9 }, 942fe4e5f8Sopenharmony_ci { 0x23, 0, sizeof(g_payLoad10), g_payLoad10 }, 952fe4e5f8Sopenharmony_ci { 0x29, 0, sizeof(g_payLoad11), g_payLoad11 }, 962fe4e5f8Sopenharmony_ci { 0x29, 0, sizeof(g_payLoad12), g_payLoad12 }, 972fe4e5f8Sopenharmony_ci { 0x29, 0, sizeof(g_payLoad13), g_payLoad13 }, 982fe4e5f8Sopenharmony_ci { 0x29, 0, sizeof(g_payLoad14), g_payLoad14 }, 992fe4e5f8Sopenharmony_ci { 0x29, 0, sizeof(g_payLoad15), g_payLoad15 }, 1002fe4e5f8Sopenharmony_ci { 0x29, 0, sizeof(g_payLoad16), g_payLoad16 }, 1012fe4e5f8Sopenharmony_ci { 0x23, 0, sizeof(g_payLoad17), g_payLoad17 }, 1022fe4e5f8Sopenharmony_ci { 0x29, 1, sizeof(g_payLoad18), g_payLoad18 }, 1032fe4e5f8Sopenharmony_ci { 0x05, 120, sizeof(g_payLoad19), g_payLoad19 }, 1042fe4e5f8Sopenharmony_ci { 0x05, 120, sizeof(g_payLoad20), g_payLoad20 }, 1052fe4e5f8Sopenharmony_ci}; 1062fe4e5f8Sopenharmony_ci 1072fe4e5f8Sopenharmony_ci/* panel1 on command payload */ 1082fe4e5f8Sopenharmony_cistatic uint8_t g_payLoad1_0[] = { 0xFF, 0x77, 0x01, 0x00, 0x00, 0x13 }; 1092fe4e5f8Sopenharmony_cistatic uint8_t g_payLoad1_1[] = { 0xEF, 0x08 }; 1102fe4e5f8Sopenharmony_cistatic uint8_t g_payLoad1_2[] = { 0xFF, 0x77, 0x01, 0x00, 0x00, 0x10 }; 1112fe4e5f8Sopenharmony_cistatic uint8_t g_payLoad1_3[] = { 0xC0, 0xF7, 0x02 }; 1122fe4e5f8Sopenharmony_cistatic uint8_t g_payLoad1_4[] = { 0xC1, 0x0C, 0x02 }; 1132fe4e5f8Sopenharmony_cistatic uint8_t g_payLoad1_5[] = { 0xC2, 0x07, 0x02 }; 1142fe4e5f8Sopenharmony_cistatic uint8_t g_payLoad1_6[] = { 0xC6, 0x21 }; 1152fe4e5f8Sopenharmony_cistatic uint8_t g_payLoad1_7[] = { 0xCC, 0x30 }; 1162fe4e5f8Sopenharmony_cistatic uint8_t g_payLoad1_8[] = { 1172fe4e5f8Sopenharmony_ci 0xB0, 0x00, 0x0B, 0x12, 0x0D, 0x11, 0x07, 0x04, 0x08, 0x07, 0x20, 0x05, 0x12, 0x0F, 0x28, 0x30, 0x1B 1182fe4e5f8Sopenharmony_ci}; 1192fe4e5f8Sopenharmony_cistatic uint8_t g_payLoad1_9[] = { 1202fe4e5f8Sopenharmony_ci 0xB1, 0x00, 0x0B, 0x12, 0x0D, 0x11, 0x05, 0x03, 0x08, 0x08, 0x20, 0x03, 0x10, 0x10, 0x29, 0x30, 0x1B 1212fe4e5f8Sopenharmony_ci}; 1222fe4e5f8Sopenharmony_cistatic uint8_t g_payLoad1_10[] = { 0xFF, 0x77, 0x01, 0x00, 0x00, 0x11 }; 1232fe4e5f8Sopenharmony_cistatic uint8_t g_payLoad1_11[] = { 0xB0, 0x4D }; 1242fe4e5f8Sopenharmony_cistatic uint8_t g_payLoad1_12[] = { 0xB1, 0x2A }; 1252fe4e5f8Sopenharmony_cistatic uint8_t g_payLoad1_13[] = { 0xB2, 0x87 }; 1262fe4e5f8Sopenharmony_cistatic uint8_t g_payLoad1_14[] = { 0xB3, 0x80 }; 1272fe4e5f8Sopenharmony_cistatic uint8_t g_payLoad1_15[] = { 0xB5, 0x49 }; 1282fe4e5f8Sopenharmony_cistatic uint8_t g_payLoad1_16[] = { 0xB7, 0x87 }; 1292fe4e5f8Sopenharmony_cistatic uint8_t g_payLoad1_17[] = { 0xB8, 0x21 }; 1302fe4e5f8Sopenharmony_cistatic uint8_t g_payLoad1_18[] = { 0xB9, 0x10 }; 1312fe4e5f8Sopenharmony_cistatic uint8_t g_payLoad1_19[] = { 0xBB, 0x00 }; 1322fe4e5f8Sopenharmony_cistatic uint8_t g_payLoad1_20[] = { 0xC0, 0x09 }; 1332fe4e5f8Sopenharmony_cistatic uint8_t g_payLoad1_21[] = { 0xC1, 0x78 }; 1342fe4e5f8Sopenharmony_cistatic uint8_t g_payLoad1_22[] = { 0xC2, 0x78 }; 1352fe4e5f8Sopenharmony_cistatic uint8_t g_payLoad1_23[] = { 0xD0, 0x88 }; 1362fe4e5f8Sopenharmony_cistatic uint8_t g_payLoad1_24[] = { 0xFF, 0x77, 0x01, 0x00, 0x00, 0x11 }; 1372fe4e5f8Sopenharmony_cistatic uint8_t g_payLoad1_25[] = { 0xE0, 0x00, 0x19, 0x00 }; 1382fe4e5f8Sopenharmony_cistatic uint8_t g_payLoad1_26[] = { 0xE1, 0x07, 0x82, 0x00, 0x82, 0x06, 0x82, 0x00, 0x82, 0x00, 0x40, 0x40 }; 1392fe4e5f8Sopenharmony_cistatic uint8_t g_payLoad1_27[] = { 1402fe4e5f8Sopenharmony_ci 0xE2, 0x30, 0x30, 0x40, 0x40, 0xCC, 0x82, 0x00, 0x82, 0xCB, 0x82, 0x00, 0x82, 0x00 1412fe4e5f8Sopenharmony_ci}; 1422fe4e5f8Sopenharmony_cistatic uint8_t g_payLoad1_28[] = { 0xE3, 0x00, 0x00, 0x33, 0x33 }; 1432fe4e5f8Sopenharmony_cistatic uint8_t g_payLoad1_29[] = { 0xE4, 0x44, 0x44 }; 1442fe4e5f8Sopenharmony_cistatic uint8_t g_payLoad1_30[] = { 1452fe4e5f8Sopenharmony_ci 0xE5, 0x09, 0xC5, 0xAA, 0x82, 0x0B, 0xC7, 0xAA, 0x82, 0x0D, 0xC9, 0xAA, 0x82, 0x0F, 0xCB, 0xAA, 0x82 1462fe4e5f8Sopenharmony_ci}; 1472fe4e5f8Sopenharmony_cistatic uint8_t g_payLoad1_31[] = { 0xE6, 0x00, 0x00, 0x33, 0x33 }; 1482fe4e5f8Sopenharmony_cistatic uint8_t g_payLoad1_32[] = { 0xE7, 0x44, 0x44 }; 1492fe4e5f8Sopenharmony_cistatic uint8_t g_payLoad1_33[] = { 1502fe4e5f8Sopenharmony_ci 0xE8, 0x08, 0xC4, 0xAA, 0x82, 0x0A, 0xC6, 0xAA, 0x82, 0x0C, 0xC8, 0xAA, 0x82, 0x0E, 0xCA, 0xAA, 0x82 1512fe4e5f8Sopenharmony_ci}; 1522fe4e5f8Sopenharmony_cistatic uint8_t g_payLoad1_34[] = { 0xEB, 0x00, 0x00, 0xE4, 0xE4, 0x88, 0x00, 0x10 }; 1532fe4e5f8Sopenharmony_cistatic uint8_t g_payLoad1_35[] = { 0xEC, 0x3D, 0x00 }; 1542fe4e5f8Sopenharmony_cistatic uint8_t g_payLoad1_36[] = { 1552fe4e5f8Sopenharmony_ci 0xED, 0xAB, 0x98, 0x76, 0x54, 0x02, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x20, 0x45, 0x67, 0x89, 0xBA 1562fe4e5f8Sopenharmony_ci}; 1572fe4e5f8Sopenharmony_cistatic uint8_t g_payLoad1_37[] = { 0xEF, 0x08, 0x08, 0x08, 0x45, 0x3F, 0x54 }; 1582fe4e5f8Sopenharmony_cistatic uint8_t g_payLoad1_38[] = { 0xFF, 0x77, 0x01, 0x00, 0x00, 0x00 }; 1592fe4e5f8Sopenharmony_cistatic uint8_t g_payLoad1_42[] = { 0x11 }; 1602fe4e5f8Sopenharmony_cistatic uint8_t g_payLoad1_43[] = { 0x29 }; 1612fe4e5f8Sopenharmony_ci 1622fe4e5f8Sopenharmony_cistruct DsiCmdDesc g_OnCmd1[] = { 1632fe4e5f8Sopenharmony_ci { 0x29, 0, sizeof(g_payLoad1_0), g_payLoad1_0 }, 1642fe4e5f8Sopenharmony_ci { 0x23, 0, sizeof(g_payLoad1_1), g_payLoad1_1 }, 1652fe4e5f8Sopenharmony_ci { 0x29, 0, sizeof(g_payLoad1_2), g_payLoad1_2 }, 1662fe4e5f8Sopenharmony_ci { 0x29, 0, sizeof(g_payLoad1_3), g_payLoad1_3 }, 1672fe4e5f8Sopenharmony_ci { 0x29, 0, sizeof(g_payLoad1_4), g_payLoad1_4 }, 1682fe4e5f8Sopenharmony_ci { 0x29, 0, sizeof(g_payLoad1_5), g_payLoad1_5 }, 1692fe4e5f8Sopenharmony_ci { 0x23, 0, sizeof(g_payLoad1_6), g_payLoad1_6 }, 1702fe4e5f8Sopenharmony_ci { 0x23, 0, sizeof(g_payLoad1_7), g_payLoad1_7 }, 1712fe4e5f8Sopenharmony_ci { 0x29, 0, sizeof(g_payLoad1_8), g_payLoad1_8 }, 1722fe4e5f8Sopenharmony_ci { 0x29, 0, sizeof(g_payLoad1_9), g_payLoad1_9 }, 1732fe4e5f8Sopenharmony_ci { 0x29, 0, sizeof(g_payLoad1_10), g_payLoad1_10 }, 1742fe4e5f8Sopenharmony_ci { 0x23, 0, sizeof(g_payLoad1_11), g_payLoad1_11 }, 1752fe4e5f8Sopenharmony_ci { 0x23, 0, sizeof(g_payLoad1_12), g_payLoad1_12 }, 1762fe4e5f8Sopenharmony_ci { 0x23, 0, sizeof(g_payLoad1_13), g_payLoad1_13 }, 1772fe4e5f8Sopenharmony_ci { 0x23, 0, sizeof(g_payLoad1_14), g_payLoad1_14 }, 1782fe4e5f8Sopenharmony_ci { 0x23, 0, sizeof(g_payLoad1_15), g_payLoad1_15 }, 1792fe4e5f8Sopenharmony_ci { 0x23, 0, sizeof(g_payLoad1_16), g_payLoad1_16 }, 1802fe4e5f8Sopenharmony_ci { 0x23, 0, sizeof(g_payLoad1_17), g_payLoad1_17 }, 1812fe4e5f8Sopenharmony_ci { 0x23, 0, sizeof(g_payLoad1_18), g_payLoad1_18 }, 1822fe4e5f8Sopenharmony_ci { 0x23, 0, sizeof(g_payLoad1_19), g_payLoad1_19 }, 1832fe4e5f8Sopenharmony_ci { 0x23, 0, sizeof(g_payLoad1_20), g_payLoad1_20 }, 1842fe4e5f8Sopenharmony_ci { 0x23, 0, sizeof(g_payLoad1_21), g_payLoad1_21 }, 1852fe4e5f8Sopenharmony_ci { 0x23, 0, sizeof(g_payLoad1_22), g_payLoad1_22 }, 1862fe4e5f8Sopenharmony_ci { 0x23, 0, sizeof(g_payLoad1_23), g_payLoad1_23 }, 1872fe4e5f8Sopenharmony_ci { 0x29, 0, sizeof(g_payLoad1_24), g_payLoad1_24 }, 1882fe4e5f8Sopenharmony_ci { 0x29, 0, sizeof(g_payLoad1_25), g_payLoad1_25 }, 1892fe4e5f8Sopenharmony_ci { 0x29, 0, sizeof(g_payLoad1_26), g_payLoad1_26 }, 1902fe4e5f8Sopenharmony_ci { 0x29, 0, sizeof(g_payLoad1_27), g_payLoad1_27 }, 1912fe4e5f8Sopenharmony_ci { 0x29, 0, sizeof(g_payLoad1_28), g_payLoad1_28 }, 1922fe4e5f8Sopenharmony_ci { 0x29, 0, sizeof(g_payLoad1_29), g_payLoad1_29 }, 1932fe4e5f8Sopenharmony_ci { 0x29, 0, sizeof(g_payLoad1_30), g_payLoad1_30 }, 1942fe4e5f8Sopenharmony_ci { 0x29, 0, sizeof(g_payLoad1_31), g_payLoad1_31 }, 1952fe4e5f8Sopenharmony_ci { 0x29, 0, sizeof(g_payLoad1_32), g_payLoad1_32 }, 1962fe4e5f8Sopenharmony_ci { 0x29, 0, sizeof(g_payLoad1_33), g_payLoad1_33 }, 1972fe4e5f8Sopenharmony_ci { 0x29, 0, sizeof(g_payLoad1_34), g_payLoad1_34 }, 1982fe4e5f8Sopenharmony_ci { 0x29, 0, sizeof(g_payLoad1_35), g_payLoad1_35 }, 1992fe4e5f8Sopenharmony_ci { 0x29, 0, sizeof(g_payLoad1_36), g_payLoad1_36 }, 2002fe4e5f8Sopenharmony_ci { 0x29, 0, sizeof(g_payLoad1_37), g_payLoad1_37 }, 2012fe4e5f8Sopenharmony_ci { 0x29, 0, sizeof(g_payLoad1_38), g_payLoad1_38 }, 2022fe4e5f8Sopenharmony_ci { 0x05, 120, sizeof(g_payLoad1_42), g_payLoad1_42 }, 2032fe4e5f8Sopenharmony_ci { 0x05, 50, sizeof(g_payLoad1_43), g_payLoad1_43 }, 2042fe4e5f8Sopenharmony_ci}; 2052fe4e5f8Sopenharmony_ci 2062fe4e5f8Sopenharmony_ci/* panel off command payload */ 2072fe4e5f8Sopenharmony_cistatic uint8_t g_offPayLoad0[] = { 0x28 }; 2082fe4e5f8Sopenharmony_cistatic uint8_t g_offPayLoad1[] = { 0x10 }; 2092fe4e5f8Sopenharmony_cistruct DsiCmdDesc g_offCmd[] = { 2102fe4e5f8Sopenharmony_ci { 0x05, 20, sizeof(g_offPayLoad0), g_offPayLoad0 }, 2112fe4e5f8Sopenharmony_ci { 0x05, 120, sizeof(g_offPayLoad1), g_offPayLoad1 }, 2122fe4e5f8Sopenharmony_ci}; 2132fe4e5f8Sopenharmony_ci 2142fe4e5f8Sopenharmony_cistatic uint8_t g_panelSolution = 0; // 0-icn9700[default], 1-ST7701SN 2152fe4e5f8Sopenharmony_ci 2162fe4e5f8Sopenharmony_cistruct Icn9700Dev { 2172fe4e5f8Sopenharmony_ci struct PanelData panel; 2182fe4e5f8Sopenharmony_ci DevHandle mipiHandle; 2192fe4e5f8Sopenharmony_ci uint16_t reset_gpio; 2202fe4e5f8Sopenharmony_ci uint16_t reset_delay; 2212fe4e5f8Sopenharmony_ci}; 2222fe4e5f8Sopenharmony_ci 2232fe4e5f8Sopenharmony_cistatic int32_t LcdResetOn(struct Icn9700Dev *icn9700) 2242fe4e5f8Sopenharmony_ci{ 2252fe4e5f8Sopenharmony_ci int32_t ret; 2262fe4e5f8Sopenharmony_ci 2272fe4e5f8Sopenharmony_ci ret = GpioSetDir(icn9700->reset_gpio, GPIO_DIR_OUT); 2282fe4e5f8Sopenharmony_ci if (ret != HDF_SUCCESS) { 2292fe4e5f8Sopenharmony_ci HDF_LOGE("GpioSetDir failed, ret:%d", ret); 2302fe4e5f8Sopenharmony_ci return HDF_FAILURE; 2312fe4e5f8Sopenharmony_ci } 2322fe4e5f8Sopenharmony_ci ret = GpioWrite(icn9700->reset_gpio, GPIO_VAL_HIGH); 2332fe4e5f8Sopenharmony_ci if (ret != HDF_SUCCESS) { 2342fe4e5f8Sopenharmony_ci HDF_LOGE("GpioWrite failed, ret:%d", ret); 2352fe4e5f8Sopenharmony_ci return HDF_FAILURE; 2362fe4e5f8Sopenharmony_ci } 2372fe4e5f8Sopenharmony_ci /* delay 20ms */ 2382fe4e5f8Sopenharmony_ci OsalMSleep(icn9700->reset_delay); 2392fe4e5f8Sopenharmony_ci return HDF_SUCCESS; 2402fe4e5f8Sopenharmony_ci} 2412fe4e5f8Sopenharmony_ci 2422fe4e5f8Sopenharmony_cistatic int32_t LcdResetOff(struct Icn9700Dev *icn9700) 2432fe4e5f8Sopenharmony_ci{ 2442fe4e5f8Sopenharmony_ci int32_t ret; 2452fe4e5f8Sopenharmony_ci 2462fe4e5f8Sopenharmony_ci ret = GpioSetDir(icn9700->reset_gpio, GPIO_DIR_OUT); 2472fe4e5f8Sopenharmony_ci if (ret != HDF_SUCCESS) { 2482fe4e5f8Sopenharmony_ci HDF_LOGE("GpioSetDir failed, ret:%d", ret); 2492fe4e5f8Sopenharmony_ci return HDF_FAILURE; 2502fe4e5f8Sopenharmony_ci } 2512fe4e5f8Sopenharmony_ci ret = GpioWrite(icn9700->reset_gpio, GPIO_VAL_LOW); 2522fe4e5f8Sopenharmony_ci if (ret != HDF_SUCCESS) { 2532fe4e5f8Sopenharmony_ci HDF_LOGE("GpioWrite failed, ret:%d", ret); 2542fe4e5f8Sopenharmony_ci return HDF_FAILURE; 2552fe4e5f8Sopenharmony_ci } 2562fe4e5f8Sopenharmony_ci /* delay 20ms */ 2572fe4e5f8Sopenharmony_ci OsalMSleep(icn9700->reset_delay); 2582fe4e5f8Sopenharmony_ci return HDF_SUCCESS; 2592fe4e5f8Sopenharmony_ci} 2602fe4e5f8Sopenharmony_ci 2612fe4e5f8Sopenharmony_cistatic struct Icn9700Dev *PanelToIcn9700Dev(const struct PanelData *panel) 2622fe4e5f8Sopenharmony_ci{ 2632fe4e5f8Sopenharmony_ci struct Icn9700Dev *icn9700 = NULL; 2642fe4e5f8Sopenharmony_ci 2652fe4e5f8Sopenharmony_ci if (panel == NULL) { 2662fe4e5f8Sopenharmony_ci HDF_LOGE("%s: panel is null", __func__); 2672fe4e5f8Sopenharmony_ci return NULL; 2682fe4e5f8Sopenharmony_ci } 2692fe4e5f8Sopenharmony_ci if (panel->object == NULL) { 2702fe4e5f8Sopenharmony_ci HDF_LOGE("%s: object is null", __func__); 2712fe4e5f8Sopenharmony_ci return NULL; 2722fe4e5f8Sopenharmony_ci } 2732fe4e5f8Sopenharmony_ci icn9700 = (struct Icn9700Dev *)panel->object->priv; 2742fe4e5f8Sopenharmony_ci return icn9700; 2752fe4e5f8Sopenharmony_ci} 2762fe4e5f8Sopenharmony_ci 2772fe4e5f8Sopenharmony_cistatic int32_t LcdCheckChipId(struct PanelData *panel) 2782fe4e5f8Sopenharmony_ci{ 2792fe4e5f8Sopenharmony_ci int32_t ret; 2802fe4e5f8Sopenharmony_ci struct Icn9700Dev *icn9700 = NULL; 2812fe4e5f8Sopenharmony_ci uint8_t payload = 0xA1; 2822fe4e5f8Sopenharmony_ci uint8_t bufRead[2] = { 0 }; 2832fe4e5f8Sopenharmony_ci struct DsiCmdDesc cmdRead = { 2842fe4e5f8Sopenharmony_ci .dataType = 0x06, /* 0x06: read data type */ 2852fe4e5f8Sopenharmony_ci .dataLen = 1, /* 1: data len */ 2862fe4e5f8Sopenharmony_ci .delay = 0, 2872fe4e5f8Sopenharmony_ci .payload = &payload, 2882fe4e5f8Sopenharmony_ci }; 2892fe4e5f8Sopenharmony_ci icn9700 = PanelToIcn9700Dev(panel); 2902fe4e5f8Sopenharmony_ci if ((icn9700 == NULL) || (icn9700->mipiHandle == NULL)) { 2912fe4e5f8Sopenharmony_ci HDF_LOGE("%s: icn9700 || mipiHandle is null", __func__); 2922fe4e5f8Sopenharmony_ci return HDF_FAILURE; 2932fe4e5f8Sopenharmony_ci } 2942fe4e5f8Sopenharmony_ci /* lcd reset power on */ 2952fe4e5f8Sopenharmony_ci ret = LcdResetOn(icn9700); 2962fe4e5f8Sopenharmony_ci if (ret != HDF_SUCCESS) { 2972fe4e5f8Sopenharmony_ci HDF_LOGE("%s: LcdResetOn failed", __func__); 2982fe4e5f8Sopenharmony_ci return HDF_FAILURE; 2992fe4e5f8Sopenharmony_ci } 3002fe4e5f8Sopenharmony_ci ret = MipiDsiRx(icn9700->mipiHandle, &cmdRead, sizeof(bufRead), bufRead); 3012fe4e5f8Sopenharmony_ci if (ret == HDF_SUCCESS) { 3022fe4e5f8Sopenharmony_ci if (bufRead[0] == 0x99) { 3032fe4e5f8Sopenharmony_ci HDF_LOGI("%s: OK: ST7701SN", __func__); 3042fe4e5f8Sopenharmony_ci g_panelSolution = 1; 3052fe4e5f8Sopenharmony_ci } else { 3062fe4e5f8Sopenharmony_ci HDF_LOGI("%s: OK: ICN9700", __func__); 3072fe4e5f8Sopenharmony_ci g_panelSolution = 0; 3082fe4e5f8Sopenharmony_ci } 3092fe4e5f8Sopenharmony_ci } else { 3102fe4e5f8Sopenharmony_ci HDF_LOGE("%s: NG: def ICN9700", __func__); 3112fe4e5f8Sopenharmony_ci } 3122fe4e5f8Sopenharmony_ci /* lcd reset power off */ 3132fe4e5f8Sopenharmony_ci ret = LcdResetOff(icn9700); 3142fe4e5f8Sopenharmony_ci return ret; 3152fe4e5f8Sopenharmony_ci} 3162fe4e5f8Sopenharmony_ci 3172fe4e5f8Sopenharmony_cistatic int32_t Icn9700Init(struct PanelData *panel) 3182fe4e5f8Sopenharmony_ci{ 3192fe4e5f8Sopenharmony_ci struct Icn9700Dev *icn9700 = NULL; 3202fe4e5f8Sopenharmony_ci 3212fe4e5f8Sopenharmony_ci icn9700 = PanelToIcn9700Dev(panel); 3222fe4e5f8Sopenharmony_ci if (icn9700 == NULL) { 3232fe4e5f8Sopenharmony_ci HDF_LOGE("%s: icn9700 is null", __func__); 3242fe4e5f8Sopenharmony_ci return HDF_FAILURE; 3252fe4e5f8Sopenharmony_ci } 3262fe4e5f8Sopenharmony_ci icn9700->mipiHandle = MipiDsiOpen(MIPI_DSI0); 3272fe4e5f8Sopenharmony_ci if (icn9700->mipiHandle == NULL) { 3282fe4e5f8Sopenharmony_ci HDF_LOGE("%s: MipiDsiOpen failed", __func__); 3292fe4e5f8Sopenharmony_ci return HDF_FAILURE; 3302fe4e5f8Sopenharmony_ci } 3312fe4e5f8Sopenharmony_ci LcdCheckChipId(panel); 3322fe4e5f8Sopenharmony_ci return HDF_SUCCESS; 3332fe4e5f8Sopenharmony_ci} 3342fe4e5f8Sopenharmony_ci 3352fe4e5f8Sopenharmony_cistatic int32_t Icn9700On(struct PanelData *panel) 3362fe4e5f8Sopenharmony_ci{ 3372fe4e5f8Sopenharmony_ci int32_t ret; 3382fe4e5f8Sopenharmony_ci struct Icn9700Dev *icn9700 = NULL; 3392fe4e5f8Sopenharmony_ci 3402fe4e5f8Sopenharmony_ci icn9700 = PanelToIcn9700Dev(panel); 3412fe4e5f8Sopenharmony_ci if (icn9700 == NULL) { 3422fe4e5f8Sopenharmony_ci HDF_LOGE("%s: icn9700 is null", __func__); 3432fe4e5f8Sopenharmony_ci return HDF_FAILURE; 3442fe4e5f8Sopenharmony_ci } 3452fe4e5f8Sopenharmony_ci /* lcd reset power on */ 3462fe4e5f8Sopenharmony_ci ret = LcdResetOn(icn9700); 3472fe4e5f8Sopenharmony_ci if (ret != HDF_SUCCESS) { 3482fe4e5f8Sopenharmony_ci HDF_LOGE("%s: LcdResetOn failed", __func__); 3492fe4e5f8Sopenharmony_ci return HDF_FAILURE; 3502fe4e5f8Sopenharmony_ci } 3512fe4e5f8Sopenharmony_ci if (icn9700->mipiHandle == NULL) { 3522fe4e5f8Sopenharmony_ci HDF_LOGE("%s: mipiHandle is null", __func__); 3532fe4e5f8Sopenharmony_ci return HDF_FAILURE; 3542fe4e5f8Sopenharmony_ci } 3552fe4e5f8Sopenharmony_ci /* send mipi init code */ 3562fe4e5f8Sopenharmony_ci int32_t count = 0; 3572fe4e5f8Sopenharmony_ci int32_t i; 3582fe4e5f8Sopenharmony_ci struct DsiCmdDesc* g_OnCmd = NULL; 3592fe4e5f8Sopenharmony_ci if (g_panelSolution == 1) { 3602fe4e5f8Sopenharmony_ci count = sizeof(g_OnCmd1) / sizeof(g_OnCmd1[0]); 3612fe4e5f8Sopenharmony_ci g_OnCmd = &(g_OnCmd1[0]); 3622fe4e5f8Sopenharmony_ci } else { 3632fe4e5f8Sopenharmony_ci count = sizeof(g_OnCmd0) / sizeof(g_OnCmd0[0]); 3642fe4e5f8Sopenharmony_ci g_OnCmd = &(g_OnCmd0[0]); 3652fe4e5f8Sopenharmony_ci } 3662fe4e5f8Sopenharmony_ci /* set mipi to lp mode */ 3672fe4e5f8Sopenharmony_ci MipiDsiSetLpMode(icn9700->mipiHandle); 3682fe4e5f8Sopenharmony_ci for (i = 0; i < count; i++) { 3692fe4e5f8Sopenharmony_ci ret = MipiDsiTx(icn9700->mipiHandle, &(g_OnCmd[i])); 3702fe4e5f8Sopenharmony_ci if (ret != HDF_SUCCESS) { 3712fe4e5f8Sopenharmony_ci HDF_LOGE("%s: MipiDsiTx failed", __func__); 3722fe4e5f8Sopenharmony_ci return HDF_FAILURE; 3732fe4e5f8Sopenharmony_ci } 3742fe4e5f8Sopenharmony_ci } 3752fe4e5f8Sopenharmony_ci /* set mipi to hs mode */ 3762fe4e5f8Sopenharmony_ci MipiDsiSetHsMode(icn9700->mipiHandle); 3772fe4e5f8Sopenharmony_ci return HDF_SUCCESS; 3782fe4e5f8Sopenharmony_ci} 3792fe4e5f8Sopenharmony_ci 3802fe4e5f8Sopenharmony_cistatic int32_t Icn9700Off(struct PanelData *panel) 3812fe4e5f8Sopenharmony_ci{ 3822fe4e5f8Sopenharmony_ci int32_t ret; 3832fe4e5f8Sopenharmony_ci struct Icn9700Dev *icn9700 = NULL; 3842fe4e5f8Sopenharmony_ci 3852fe4e5f8Sopenharmony_ci icn9700 = PanelToIcn9700Dev(panel); 3862fe4e5f8Sopenharmony_ci if (icn9700 == NULL) { 3872fe4e5f8Sopenharmony_ci HDF_LOGE("%s: icn9700 is null", __func__); 3882fe4e5f8Sopenharmony_ci return HDF_FAILURE; 3892fe4e5f8Sopenharmony_ci } 3902fe4e5f8Sopenharmony_ci if (icn9700->mipiHandle == NULL) { 3912fe4e5f8Sopenharmony_ci HDF_LOGE("%s: mipiHandle is null", __func__); 3922fe4e5f8Sopenharmony_ci return HDF_FAILURE; 3932fe4e5f8Sopenharmony_ci } 3942fe4e5f8Sopenharmony_ci /* send mipi init code */ 3952fe4e5f8Sopenharmony_ci int32_t count = sizeof(g_offCmd) / sizeof(g_offCmd[0]); 3962fe4e5f8Sopenharmony_ci int32_t i; 3972fe4e5f8Sopenharmony_ci /* set mipi to lp mode */ 3982fe4e5f8Sopenharmony_ci MipiDsiSetLpMode(icn9700->mipiHandle); 3992fe4e5f8Sopenharmony_ci for (i = 0; i < count; i++) { 4002fe4e5f8Sopenharmony_ci ret = MipiDsiTx(icn9700->mipiHandle, &(g_offCmd[i])); 4012fe4e5f8Sopenharmony_ci if (ret != HDF_SUCCESS) { 4022fe4e5f8Sopenharmony_ci HDF_LOGE("%s: MipiDsiTx failed", __func__); 4032fe4e5f8Sopenharmony_ci return HDF_FAILURE; 4042fe4e5f8Sopenharmony_ci } 4052fe4e5f8Sopenharmony_ci } 4062fe4e5f8Sopenharmony_ci /* lcd reset power off */ 4072fe4e5f8Sopenharmony_ci ret = LcdResetOff(icn9700); 4082fe4e5f8Sopenharmony_ci if (ret != HDF_SUCCESS) { 4092fe4e5f8Sopenharmony_ci HDF_LOGE("%s: LcdResetOff failed", __func__); 4102fe4e5f8Sopenharmony_ci return HDF_FAILURE; 4112fe4e5f8Sopenharmony_ci } 4122fe4e5f8Sopenharmony_ci return HDF_SUCCESS; 4132fe4e5f8Sopenharmony_ci} 4142fe4e5f8Sopenharmony_ci 4152fe4e5f8Sopenharmony_cistatic int32_t Icn9700EsdCheckFunc(struct PanelData *panel) 4162fe4e5f8Sopenharmony_ci{ 4172fe4e5f8Sopenharmony_ci struct Icn9700Dev *icn9700 = NULL; 4182fe4e5f8Sopenharmony_ci 4192fe4e5f8Sopenharmony_ci icn9700 = PanelToIcn9700Dev(panel); 4202fe4e5f8Sopenharmony_ci if (icn9700 == NULL) { 4212fe4e5f8Sopenharmony_ci HDF_LOGE("%s: icn9700 is null", __func__); 4222fe4e5f8Sopenharmony_ci return HDF_FAILURE; 4232fe4e5f8Sopenharmony_ci } 4242fe4e5f8Sopenharmony_ci HDF_LOGE("%s: enter", __func__); 4252fe4e5f8Sopenharmony_ci return HDF_SUCCESS; 4262fe4e5f8Sopenharmony_ci} 4272fe4e5f8Sopenharmony_ci 4282fe4e5f8Sopenharmony_ci#define OUTPUT_USER 0 /* output timing type */ 4292fe4e5f8Sopenharmony_cistatic struct PanelInfo g_panelInfo = { 4302fe4e5f8Sopenharmony_ci .width = WIDTH1, /* width */ 4312fe4e5f8Sopenharmony_ci .height = HEIGHT1, /* height */ 4322fe4e5f8Sopenharmony_ci .hbp = HORIZONTAL_BACK_PORCH1, /* horizontal back porch */ 4332fe4e5f8Sopenharmony_ci .hfp = HORIZONTAL_FRONT_PORCH1, /* horizontal front porch */ 4342fe4e5f8Sopenharmony_ci .hsw = HORIZONTAL_SYNC_WIDTH1, /* horizontal sync width */ 4352fe4e5f8Sopenharmony_ci .vbp = VERTICAL_BACK_PORCH1, /* vertical back porch */ 4362fe4e5f8Sopenharmony_ci .vfp = VERTICAL_FRONT_PORCH1, /* vertical front porch */ 4372fe4e5f8Sopenharmony_ci .vsw = VERTICAL_SYNC_WIDTH1, /* vertical sync width */ 4382fe4e5f8Sopenharmony_ci .frameRate = FRAME_RATE1, /* frame rate */ 4392fe4e5f8Sopenharmony_ci .intfType = MIPI_DSI, /* panel interface type */ 4402fe4e5f8Sopenharmony_ci .intfSync = OUTPUT_USER, 4412fe4e5f8Sopenharmony_ci /* mipi config info */ 4422fe4e5f8Sopenharmony_ci .mipi = { DSI_2_LANES, DSI_VIDEO_MODE, VIDEO_BURST_MODE, FORMAT_RGB_24_BIT }, 4432fe4e5f8Sopenharmony_ci /* backlight config info */ 4442fe4e5f8Sopenharmony_ci .blk = { BLK_PWM, MIN_LEVEL, MAX_LEVEL, DEFAULT_LEVEL }, 4452fe4e5f8Sopenharmony_ci .pwm = { BLK_PWM1, PWM_MAX_PERIOD }, 4462fe4e5f8Sopenharmony_ci}; 4472fe4e5f8Sopenharmony_ci 4482fe4e5f8Sopenharmony_cistatic struct PanelEsd g_panelEsd = { 4492fe4e5f8Sopenharmony_ci .support = false, 4502fe4e5f8Sopenharmony_ci .checkFunc = Icn9700EsdCheckFunc, 4512fe4e5f8Sopenharmony_ci}; 4522fe4e5f8Sopenharmony_ci 4532fe4e5f8Sopenharmony_cistatic void Icn9700PanelInit(struct PanelData *panel) 4542fe4e5f8Sopenharmony_ci{ 4552fe4e5f8Sopenharmony_ci panel->info = &g_panelInfo; 4562fe4e5f8Sopenharmony_ci panel->esd = &g_panelEsd; 4572fe4e5f8Sopenharmony_ci panel->init = Icn9700Init; 4582fe4e5f8Sopenharmony_ci panel->on = Icn9700On; 4592fe4e5f8Sopenharmony_ci panel->off = Icn9700Off; 4602fe4e5f8Sopenharmony_ci} 4612fe4e5f8Sopenharmony_ci 4622fe4e5f8Sopenharmony_cistatic int32_t Icn9700EntryInit(struct HdfDeviceObject *object) 4632fe4e5f8Sopenharmony_ci{ 4642fe4e5f8Sopenharmony_ci struct Icn9700Dev *icn9700 = NULL; 4652fe4e5f8Sopenharmony_ci 4662fe4e5f8Sopenharmony_ci if (object == NULL) { 4672fe4e5f8Sopenharmony_ci HDF_LOGE("%s: object is null", __func__); 4682fe4e5f8Sopenharmony_ci return HDF_FAILURE; 4692fe4e5f8Sopenharmony_ci } 4702fe4e5f8Sopenharmony_ci icn9700 = (struct Icn9700Dev *)OsalMemCalloc(sizeof(struct Icn9700Dev)); 4712fe4e5f8Sopenharmony_ci if (icn9700 == NULL) { 4722fe4e5f8Sopenharmony_ci HDF_LOGE("%s icn9700 malloc fail", __func__); 4732fe4e5f8Sopenharmony_ci return HDF_FAILURE; 4742fe4e5f8Sopenharmony_ci } 4752fe4e5f8Sopenharmony_ci Icn9700PanelInit(&icn9700->panel); 4762fe4e5f8Sopenharmony_ci icn9700->panel.object = object; 4772fe4e5f8Sopenharmony_ci icn9700->reset_gpio = RESET_GPIO; 4782fe4e5f8Sopenharmony_ci icn9700->reset_delay = 20; // delay 20ms 4792fe4e5f8Sopenharmony_ci object->priv = (void *)icn9700; 4802fe4e5f8Sopenharmony_ci icn9700->panel.blDev = GetBacklightDev("hdf_pwm"); 4812fe4e5f8Sopenharmony_ci if (icn9700->panel.blDev == NULL) { 4822fe4e5f8Sopenharmony_ci HDF_LOGE("%s GetBacklightDev fail", __func__); 4832fe4e5f8Sopenharmony_ci return HDF_FAILURE; 4842fe4e5f8Sopenharmony_ci } 4852fe4e5f8Sopenharmony_ci if (RegisterPanel(&icn9700->panel) != HDF_SUCCESS) { 4862fe4e5f8Sopenharmony_ci HDF_LOGE("%s: RegisterPanel failed", __func__); 4872fe4e5f8Sopenharmony_ci return HDF_FAILURE; 4882fe4e5f8Sopenharmony_ci } 4892fe4e5f8Sopenharmony_ci HDF_LOGI("%s: exit succ", __func__); 4902fe4e5f8Sopenharmony_ci return HDF_SUCCESS; 4912fe4e5f8Sopenharmony_ci} 4922fe4e5f8Sopenharmony_ci 4932fe4e5f8Sopenharmony_cistruct HdfDriverEntry g_icn9700DevEntry = { 4942fe4e5f8Sopenharmony_ci .moduleVersion = 1, 4952fe4e5f8Sopenharmony_ci .moduleName = "LCD_ICN9700", 4962fe4e5f8Sopenharmony_ci .Init = Icn9700EntryInit, 4972fe4e5f8Sopenharmony_ci}; 4982fe4e5f8Sopenharmony_ci 4992fe4e5f8Sopenharmony_ciHDF_INIT(g_icn9700DevEntry); 500