xref: /OK3568_Linux_fs/kernel/sound/soc/codecs/aw87xxx/aw_bin_parse.h (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1 /* SPDX-License-Identifier: GPL-2.0+ */
2 
3 #ifndef __AW_BIN_PARSE_H__
4 #define __AW_BIN_PARSE_H__
5 
6 #define NULL    ((void *)0)
7 #define GET_32_DATA(w, x, y, z) ((unsigned int)(((w) << 24) | ((x) << 16) | ((y) << 8) | (z)))
8 #define BIN_NUM_MAX   100
9 #define HEADER_LEN    60
10 /*********************************************************
11  *
12  * header information
13  *
14  ********************************************************/
15 enum bin_header_version_enum {
16 	HEADER_VERSION_1_0_0 = 0x01000000,
17 };
18 
19 enum data_type_enum {
20 	DATA_TYPE_REGISTER = 0x00000000,
21 	DATA_TYPE_DSP_REG = 0x00000010,
22 	DATA_TYPE_DSP_CFG = 0x00000011,
23 	DATA_TYPE_SOC_REG = 0x00000020,
24 	DATA_TYPE_SOC_APP = 0x00000021,
25 	DATA_TYPE_MULTI_BINS = 0x00002000,
26 	DATA_TYPE_MONITOR_ANALOG = 0x00020000,
27 };
28 
29 enum data_version_enum {
30 	DATA_VERSION_V1 = 0X00000001,	/*default little edian */
31 	DATA_VERSION_MAX,
32 };
33 
34 struct bin_header_info {
35 	unsigned int header_len; /* Frame header length */
36 	unsigned int check_sum; /* Frame header information-Checksum */
37 	unsigned int header_ver; /* Frame header information-Frame header version */
38 	unsigned int bin_data_type; /* Frame header information-Data type */
39 	unsigned int bin_data_ver; /* Frame header information-Data version */
40 	unsigned int bin_data_len; /* Frame header information-Data length */
41 	unsigned int ui_ver; /* Frame header information-ui version */
42 	unsigned char chip_type[8]; /* Frame header information-chip type */
43 	unsigned int reg_byte_len; /* Frame header information-reg byte len */
44 	unsigned int data_byte_len; /* Frame header information-data byte len */
45 	unsigned int device_addr; /* Frame header information-device addr */
46 	unsigned int valid_data_len; /* Length of valid data obtained after parsing */
47 	unsigned int valid_data_addr; /* The offset address of the valid data obtained after parsing relative to info */
48 
49 	unsigned int reg_num; /* The number of registers obtained after parsing */
50 	unsigned int reg_data_byte_len; /* The byte length of the register obtained after parsing */
51 	unsigned int download_addr; /* The starting address or download address obtained after parsing */
52 	unsigned int app_version; /* The software version number obtained after parsing */
53 };
54 
55 /************************************************************
56 *
57 * function define
58 *
59 ************************************************************/
60 struct bin_container {
61 	unsigned int len; /* The size of the bin file obtained from the firmware */
62 	unsigned char data[]; /* Store the bin file obtained from the firmware */
63 };
64 
65 struct aw_bin {
66 	char *p_addr; /* Offset pointer (backward offset pointer to obtain frame header information and important information) */
67 	unsigned int all_bin_parse_num; /* The number of all bin files */
68 	unsigned int multi_bin_parse_num; /* The number of single bin files */
69 	unsigned int single_bin_parse_num; /* The number of multiple bin files */
70 	struct bin_header_info header_info[BIN_NUM_MAX]; /* Frame header information and other important data obtained after parsing */
71 	struct bin_container info; /* Obtained bin file data that needs to be parsed */
72 };
73 
74 extern int aw_parsing_bin_file(struct aw_bin *bin);
75 int aw_parse_bin_header_1_0_0(struct aw_bin *bin);
76 #endif
77