blob: b61f2784562513213c03d78f3a19a48f8fd83698 [file] [log] [blame] [edit]
/*
* drivers/display/lcd/aml_lcd_unifykey.h
*
* Copyright (C) 2015 Amlogic, Inc. All rights reserved.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* 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 __AML_LCD_UNIFYKEY_H__
#define __AML_LCD_UNIFYKEY_H__
#define LCD_UKEY_RETRY_CNT_MAX 5
/*
lcd unifykey data struct: little-endian, for example:
4byte: d[0]=0x01, d[1]=0x02, d[2] = 0x03, d[3]= 0x04,
data = 0x04030201
*/
/* define lcd unifykey length */
#define LCD_UKEY_HEAD_SIZE 10
#define LCD_UKEY_HEAD_CRC32 4
#define LCD_UKEY_HEAD_DATA_LEN 2
#define LCD_UKEY_HEAD_VERSION 2
#define LCD_UKEY_HEAD_RESERVED 2
struct aml_lcd_unifykey_header_s {
unsigned int crc32;
unsigned short data_len;
unsigned short version;
unsigned short reserved;
};
/* ********************************
* lcd
* ********************************* */
/* V1: 265 */
/* V2: 319 */
#define LCD_UKEY_LCD_SIZE 319
/* header (10Byte) */
/* LCD_UKEY_HEAD_SIZE */
/* basic (36Byte) */
#define LCD_UKEY_MODEL_NAME (LCD_UKEY_HEAD_SIZE + 0)
#define LCD_UKEY_INTERFACE (LCD_UKEY_MODEL_NAME + 30)
#define LCD_UKEY_LCD_BITS (LCD_UKEY_MODEL_NAME + 31)
#define LCD_UKEY_SCREEN_WIDTH (LCD_UKEY_MODEL_NAME + 32)
#define LCD_UKEY_SCREEN_HEIGHT (LCD_UKEY_MODEL_NAME + 34)
/* timing (18Byte) */
#define LCD_UKEY_H_ACTIVE (LCD_UKEY_MODEL_NAME + 36)/* +36 byte */
#define LCD_UKEY_V_ACTIVE (LCD_UKEY_MODEL_NAME + 38)
#define LCD_UKEY_H_PERIOD (LCD_UKEY_MODEL_NAME + 40)
#define LCD_UKEY_V_PERIOD (LCD_UKEY_MODEL_NAME + 42)
#define LCD_UKEY_HS_WIDTH (LCD_UKEY_MODEL_NAME + 44)
#define LCD_UKEY_HS_BP (LCD_UKEY_MODEL_NAME + 46)
#define LCD_UKEY_HS_POL (LCD_UKEY_MODEL_NAME + 48)
#define LCD_UKEY_VS_WIDTH (LCD_UKEY_MODEL_NAME + 49)
#define LCD_UKEY_VS_BP (LCD_UKEY_MODEL_NAME + 51)
#define LCD_UKEY_VS_POL (LCD_UKEY_MODEL_NAME + 53)
/* customer (31Byte) */
#define LCD_UKEY_FR_ADJ_TYPE (LCD_UKEY_MODEL_NAME + 54)/* +36+18 byte */
#define LCD_UKEY_SS_LEVEL (LCD_UKEY_MODEL_NAME + 55)
#define LCD_UKEY_CLK_AUTO_GEN (LCD_UKEY_MODEL_NAME + 56)
#define LCD_UKEY_PCLK (LCD_UKEY_MODEL_NAME + 57)
#define LCD_UKEY_H_PERIOD_MIN (LCD_UKEY_MODEL_NAME + 61)
#define LCD_UKEY_H_PERIOD_MAX (LCD_UKEY_MODEL_NAME + 63)
#define LCD_UKEY_V_PERIOD_MIN (LCD_UKEY_MODEL_NAME + 65)
#define LCD_UKEY_V_PERIOD_MAX (LCD_UKEY_MODEL_NAME + 67)
#define LCD_UKEY_PCLK_MIN (LCD_UKEY_MODEL_NAME + 69)
#define LCD_UKEY_PCLK_MAX (LCD_UKEY_MODEL_NAME + 73)
#define LCD_UKEY_CUST_VAL_8 (LCD_UKEY_MODEL_NAME + 77)
#define LCD_UKEY_CUST_VAL_9 (LCD_UKEY_MODEL_NAME + 81)
/* interface (20Byte) */
#define LCD_UKEY_IF_ATTR_0 (LCD_UKEY_MODEL_NAME + 85)/* +36+18+31 byte */
#define LCD_UKEY_IF_ATTR_1 (LCD_UKEY_MODEL_NAME + 87)
#define LCD_UKEY_IF_ATTR_2 (LCD_UKEY_MODEL_NAME + 89)
#define LCD_UKEY_IF_ATTR_3 (LCD_UKEY_MODEL_NAME + 91)
#define LCD_UKEY_IF_ATTR_4 (LCD_UKEY_MODEL_NAME + 93)
#define LCD_UKEY_IF_ATTR_5 (LCD_UKEY_MODEL_NAME + 95)
#define LCD_UKEY_IF_ATTR_6 (LCD_UKEY_MODEL_NAME + 97)
#define LCD_UKEY_IF_ATTR_7 (LCD_UKEY_MODEL_NAME + 99)
#define LCD_UKEY_IF_ATTR_8 (LCD_UKEY_MODEL_NAME + 101)
#define LCD_UKEY_IF_ATTR_9 (LCD_UKEY_MODEL_NAME + 103)
/* ctrl (44Byte) */ /* V2 */
#define LCD_UKEY_CTRL_FLAG (LCD_UKEY_MODEL_NAME + 105)/* +36+18+31+20 byte */
#define LCD_UKEY_CTRL_ATTR_0 (LCD_UKEY_MODEL_NAME + 109)
#define LCD_UKEY_CTRL_ATTR_1 (LCD_UKEY_MODEL_NAME + 111)
#define LCD_UKEY_CTRL_ATTR_2 (LCD_UKEY_MODEL_NAME + 113)
#define LCD_UKEY_CTRL_ATTR_3 (LCD_UKEY_MODEL_NAME + 115)
#define LCD_UKEY_CTRL_ATTR_4 (LCD_UKEY_MODEL_NAME + 117)
#define LCD_UKEY_CTRL_ATTR_5 (LCD_UKEY_MODEL_NAME + 119)
#define LCD_UKEY_CTRL_ATTR_6 (LCD_UKEY_MODEL_NAME + 121)
#define LCD_UKEY_CTRL_ATTR_7 (LCD_UKEY_MODEL_NAME + 123)
#define LCD_UKEY_CTRL_ATTR_8 (LCD_UKEY_MODEL_NAME + 125)
#define LCD_UKEY_CTRL_ATTR_9 (LCD_UKEY_MODEL_NAME + 127)
#define LCD_UKEY_CTRL_ATTR_10 (LCD_UKEY_MODEL_NAME + 129)
#define LCD_UKEY_CTRL_ATTR_11 (LCD_UKEY_MODEL_NAME + 131)
#define LCD_UKEY_CTRL_ATTR_12 (LCD_UKEY_MODEL_NAME + 133)
#define LCD_UKEY_CTRL_ATTR_13 (LCD_UKEY_MODEL_NAME + 135)
#define LCD_UKEY_CTRL_ATTR_14 (LCD_UKEY_MODEL_NAME + 137)
#define LCD_UKEY_CTRL_ATTR_15 (LCD_UKEY_MODEL_NAME + 139)
#define LCD_UKEY_CTRL_ATTR_16 (LCD_UKEY_MODEL_NAME + 141)
#define LCD_UKEY_CTRL_ATTR_17 (LCD_UKEY_MODEL_NAME + 143)
#define LCD_UKEY_CTRL_ATTR_18 (LCD_UKEY_MODEL_NAME + 145)
#define LCD_UKEY_CTRL_ATTR_19 (LCD_UKEY_MODEL_NAME + 147)
/* phy (10Byte) */ /* V2 */
#define LCD_UKEY_PHY_ATTR_0 (LCD_UKEY_MODEL_NAME + 149)/* +36+18+31+20+44 byte */
#define LCD_UKEY_PHY_ATTR_1 (LCD_UKEY_MODEL_NAME + 150)
#define LCD_UKEY_PHY_ATTR_2 (LCD_UKEY_MODEL_NAME + 151)
#define LCD_UKEY_PHY_ATTR_3 (LCD_UKEY_MODEL_NAME + 152)
#define LCD_UKEY_PHY_ATTR_4 (LCD_UKEY_MODEL_NAME + 153)
#define LCD_UKEY_PHY_ATTR_5 (LCD_UKEY_MODEL_NAME + 154)
#define LCD_UKEY_PHY_ATTR_6 (LCD_UKEY_MODEL_NAME + 155)
#define LCD_UKEY_PHY_ATTR_7 (LCD_UKEY_MODEL_NAME + 156)
#define LCD_UKEY_PHY_ATTR_8 (LCD_UKEY_MODEL_NAME + 157)
#define LCD_UKEY_PHY_ATTR_9 (LCD_UKEY_MODEL_NAME + 158)
#define LCD_UKEY_DATA_LEN_V1 (LCD_UKEY_MODEL_NAME + 105)
#define LCD_UKEY_DATA_LEN_V2 (LCD_UKEY_MODEL_NAME + 159)
/* power (5Byte * n) */
/* v1/v2 p + offsite*/
/* 10+36+18+31+20 byte */
/* 10+36+18+31+20+44+10 byte */
#define LCD_UKEY_PWR_TYPE (0)
#define LCD_UKEY_PWR_INDEX (1)
#define LCD_UKEY_PWR_VAL (2)
#define LCD_UKEY_PWR_DELAY (3)
/* ********************************
* lcd extern
* ********************************* */
#define LCD_UKEY_LCD_EXT_SIZE 550
/* header (10Byte) */
/* LCD_UKEY_HEAD_SIZE */
/* basic (33Byte) */
#define LCD_UKEY_EXT_NAME (LCD_UKEY_HEAD_SIZE + 0)
#define LCD_UKEY_EXT_INDEX (LCD_UKEY_EXT_NAME + 30)
#define LCD_UKEY_EXT_TYPE (LCD_UKEY_EXT_NAME + 31)
#define LCD_UKEY_EXT_STATUS (LCD_UKEY_EXT_NAME + 32)
/* type (10Byte) */
#define LCD_UKEY_EXT_TYPE_VAL_0 (LCD_UKEY_EXT_NAME + 33)/* +33 byte */
#define LCD_UKEY_EXT_TYPE_VAL_1 (LCD_UKEY_EXT_NAME + 34)
#define LCD_UKEY_EXT_TYPE_VAL_2 (LCD_UKEY_EXT_NAME + 35)
#define LCD_UKEY_EXT_TYPE_VAL_3 (LCD_UKEY_EXT_NAME + 36)
#define LCD_UKEY_EXT_TYPE_VAL_4 (LCD_UKEY_EXT_NAME + 37)
#define LCD_UKEY_EXT_TYPE_VAL_5 (LCD_UKEY_EXT_NAME + 38)
#define LCD_UKEY_EXT_TYPE_VAL_6 (LCD_UKEY_EXT_NAME + 39)
#define LCD_UKEY_EXT_TYPE_VAL_7 (LCD_UKEY_EXT_NAME + 40)
#define LCD_UKEY_EXT_TYPE_VAL_8 (LCD_UKEY_EXT_NAME + 41)
#define LCD_UKEY_EXT_TYPE_VAL_9 (LCD_UKEY_EXT_NAME + 42)
/* init (cmd_size) */
#define LCD_UKEY_EXT_INIT (LCD_UKEY_EXT_NAME + 43)/* +33+10 byte */
/*#define LCD_UKEY_EXT_INIT_TYPE (0)*/
/*#define LCD_UKEY_EXT_INIT_VAL (1)*/
/*#define LCD_UKEY_EXT_INIT_DELAY (n)*/
/* ********************************
* backlight
* ********************************* */
/* V1: 92 */
/* V2: 102 */
#define LCD_UKEY_BL_SIZE 102
/* header (10Byte) */
/* LCD_UKEY_HEAD_SIZE */
/* basic (30Byte) */
#define LCD_UKEY_BL_NAME (LCD_UKEY_HEAD_SIZE + 0)
/* level (12Byte) */
#define LCD_UKEY_BL_LEVEL_UBOOT (LCD_UKEY_BL_NAME + 30)/* +30 byte */
#define LCD_UKEY_BL_LEVEL_KERNEL (LCD_UKEY_BL_NAME + 32)
#define LCD_UKEY_BL_LEVEL_MAX (LCD_UKEY_BL_NAME + 34)
#define LCD_UKEY_BL_LEVEL_MIN (LCD_UKEY_BL_NAME + 36)
#define LCD_UKEY_BL_LEVEL_MID (LCD_UKEY_BL_NAME + 38)
#define LCD_UKEY_BL_LEVEL_MID_MAP (LCD_UKEY_BL_NAME + 40)
/* method (8Byte) */
#define LCD_UKEY_BL_METHOD (LCD_UKEY_BL_NAME + 42)/* +30+12 byte */
#define LCD_UKEY_BL_EN_GPIO (LCD_UKEY_BL_NAME + 43)
#define LCD_UKEY_BL_EN_GPIO_ON (LCD_UKEY_BL_NAME + 44)
#define LCD_UKEY_BL_EN_GPIO_OFF (LCD_UKEY_BL_NAME + 45)
#define LCD_UKEY_BL_ON_DELAY (LCD_UKEY_BL_NAME + 46)
#define LCD_UKEY_BL_OFF_DELAY (LCD_UKEY_BL_NAME + 48)
/* pwm (32Byte) */
#define LCD_UKEY_BL_PWM_ON_DELAY (LCD_UKEY_BL_NAME + 50)/* +30+12+8 byte */
#define LCD_UKEY_BL_PWM_OFF_DELAY (LCD_UKEY_BL_NAME + 52)
#define LCD_UKEY_BL_PWM_METHOD (LCD_UKEY_BL_NAME + 54)
#define LCD_UKEY_BL_PWM_PORT (LCD_UKEY_BL_NAME + 55)
#define LCD_UKEY_BL_PWM_FREQ (LCD_UKEY_BL_NAME + 56)
#define LCD_UKEY_BL_PWM_DUTY_MAX (LCD_UKEY_BL_NAME + 60)
#define LCD_UKEY_BL_PWM_DUTY_MIN (LCD_UKEY_BL_NAME + 61)
#define LCD_UKEY_BL_PWM_GPIO (LCD_UKEY_BL_NAME + 62)
#define LCD_UKEY_BL_PWM_GPIO_OFF (LCD_UKEY_BL_NAME + 63)
#define LCD_UKEY_BL_PWM2_METHOD (LCD_UKEY_BL_NAME + 64)
#define LCD_UKEY_BL_PWM2_PORT (LCD_UKEY_BL_NAME + 65)
#define LCD_UKEY_BL_PWM2_FREQ (LCD_UKEY_BL_NAME + 66)
#define LCD_UKEY_BL_PWM2_DUTY_MAX (LCD_UKEY_BL_NAME + 70)
#define LCD_UKEY_BL_PWM2_DUTY_MIN (LCD_UKEY_BL_NAME + 71)
#define LCD_UKEY_BL_PWM2_GPIO (LCD_UKEY_BL_NAME + 72)
#define LCD_UKEY_BL_PWM2_GPIO_OFF (LCD_UKEY_BL_NAME + 73)
#define LCD_UKEY_BL_PWM_LEVEL_MAX (LCD_UKEY_BL_NAME + 74)
#define LCD_UKEY_BL_PWM_LEVEL_MIN (LCD_UKEY_BL_NAME + 76)
#define LCD_UKEY_BL_PWM2_LEVEL_MAX (LCD_UKEY_BL_NAME + 78)
#define LCD_UKEY_BL_PWM2_LEVEL_MIN (LCD_UKEY_BL_NAME + 80)
/* customer(10Byte) */ /* V2 */
#define LCD_UKEY_BL_CUST_VAL_0 (LCD_UKEY_BL_NAME + 82)/* +30+12+8+32 byte */
#define LCD_UKEY_BL_CUST_VAL_1 (LCD_UKEY_BL_NAME + 84)
#define LCD_UKEY_BL_CUST_VAL_2 (LCD_UKEY_BL_NAME + 86)
#define LCD_UKEY_BL_CUST_VAL_3 (LCD_UKEY_BL_NAME + 88)
#define LCD_UKEY_BL_CUST_VAL_4 (LCD_UKEY_BL_NAME + 90)
/* ********************************
* tcon
* ********************************* */
#define LCD_UKEY_TCON_SIZE 4096
/* ********************************
* debug flag
* ********************************* */
#define LCD_UKEY_DEBUG_NORMAL (1 << 0)
#define LCD_UKEY_DEBUG_TCON (1 << 1)
/* ********************************
* API
* ********************************* */
extern int aml_lcd_unifykey_len_check(int key_len, int len);
extern int aml_lcd_unifykey_header_check(unsigned char *buf, struct aml_lcd_unifykey_header_s *header);
extern int aml_lcd_unifykey_check(const char *key_name);
extern int aml_lcd_unifykey_get(const char *key_name, unsigned char *buf, int *len);
extern int aml_lcd_unifykey_check_no_header(const char *key_name);
extern int aml_lcd_unifykey_get_no_header(const char *key_name, unsigned char *buf, int *len);
extern void aml_lcd_unifykey_test(void);
extern void aml_lcd_unifykey_tcon_test(int n);
extern void aml_lcd_unifykey_dump(int flag);
#endif