WIP FPC-III support
[linux/fpc-iii.git] / drivers / media / i2c / ccs / ccs-data.h
blob50d6508b24f381046b6298363c10ea61e929c5e5
1 /* SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause */
2 /*
3 * CCS static data in-memory data structure definitions
5 * Copyright 2019--2020 Intel Corporation
6 */
8 #ifndef __CCS_DATA_H__
9 #define __CCS_DATA_H__
11 #include <linux/types.h>
13 /**
14 * struct ccs_data_block_version - CCS static data version
15 * @version_major: Major version number
16 * @version_minor: Minor version number
17 * @date_year: Year
18 * @date_month: Month
19 * @date_day: Day
21 struct ccs_data_block_version {
22 u16 version_major;
23 u16 version_minor;
24 u16 date_year;
25 u8 date_month;
26 u8 date_day;
29 /**
30 * struct ccs_reg - CCS register value
31 * @addr: The 16-bit address of the register
32 * @len: Length of the data
33 * @value: Data
35 struct ccs_reg {
36 u16 addr;
37 u16 len;
38 u8 *value;
41 /**
42 * struct ccs_if_rule - CCS static data if rule
43 * @addr: Register address
44 * @value: Register value
45 * @mask: Value applied to both actual register value and @value
47 struct ccs_if_rule {
48 u16 addr;
49 u8 value;
50 u8 mask;
53 /**
54 * struct ccs_frame_format_desc - CCS frame format descriptor
55 * @pixelcode: The pixelcode; CCS_DATA_BLOCK_FFD_PIXELCODE_*
56 * @value: Value related to the pixelcode
58 struct ccs_frame_format_desc {
59 u8 pixelcode;
60 u16 value;
63 /**
64 * struct ccs_frame_format_descs - A series of CCS frame format descriptors
65 * @num_column_descs: Number of column descriptors
66 * @num_row_descs: Number of row descriptors
67 * @column_descs: Column descriptors
68 * @row_descs: Row descriptors
70 struct ccs_frame_format_descs {
71 u8 num_column_descs;
72 u8 num_row_descs;
73 struct ccs_frame_format_desc *column_descs;
74 struct ccs_frame_format_desc *row_descs;
77 /**
78 * struct ccs_pdaf_readout - CCS PDAF data readout descriptor
79 * @pdaf_readout_info_order: PDAF readout order
80 * @ffd: Frame format of PDAF data
82 struct ccs_pdaf_readout {
83 u8 pdaf_readout_info_order;
84 struct ccs_frame_format_descs *ffd;
87 /**
88 * struct ccs_rule - A CCS static data rule
89 * @num_if_rules: Number of if rules
90 * @if_rules: If rules
91 * @num_read_only_regs: Number of read-only registers
92 * @read_only_regs: Read-only registers
93 * @num_manufacturer_regs: Number of manufacturer-specific registers
94 * @manufacturer_regs: Manufacturer-specific registers
95 * @frame_format: Frame format
96 * @pdaf_readout: PDAF readout
98 struct ccs_rule {
99 size_t num_if_rules;
100 struct ccs_if_rule *if_rules;
101 size_t num_read_only_regs;
102 struct ccs_reg *read_only_regs;
103 size_t num_manufacturer_regs;
104 struct ccs_reg *manufacturer_regs;
105 struct ccs_frame_format_descs *frame_format;
106 struct ccs_pdaf_readout *pdaf_readout;
110 * struct ccs_pdaf_pix_loc_block_desc - PDAF pixel location block descriptor
111 * @block_type_id: Block type identifier, from 0 to n
112 * @repeat_x: Number of times this block is repeated to right
114 struct ccs_pdaf_pix_loc_block_desc {
115 u8 block_type_id;
116 u16 repeat_x;
120 * struct ccs_pdaf_pix_loc_block_desc_group - PDAF pixel location block
121 * descriptor group
122 * @repeat_y: Number of times the group is repeated down
123 * @num_block_descs: Number of block descriptors in @block_descs
124 * @block_descs: Block descriptors
126 struct ccs_pdaf_pix_loc_block_desc_group {
127 u8 repeat_y;
128 u16 num_block_descs;
129 struct ccs_pdaf_pix_loc_block_desc *block_descs;
133 * struct ccs_pdaf_pix_loc_block_desc - PDAF pixel location block descriptor
134 * @pixel_type: Type of the pixel; CCS_DATA_PDAF_PIXEL_TYPE_*
135 * @small_offset_x: offset X coordinate
136 * @small_offset_y: offset Y coordinate
138 struct ccs_pdaf_pix_loc_pixel_desc {
139 u8 pixel_type;
140 u8 small_offset_x;
141 u8 small_offset_y;
145 * struct ccs_pdaf_pix_loc_pixel_desc_group - PDAF pixel location pixel
146 * descriptor group
147 * @num_descs: Number of descriptors in @descs
148 * @descs: PDAF pixel location pixel descriptors
150 struct ccs_pdaf_pix_loc_pixel_desc_group {
151 u8 num_descs;
152 struct ccs_pdaf_pix_loc_pixel_desc *descs;
156 * struct ccs_pdaf_pix_loc - PDAF pixel locations
157 * @main_offset_x: Start X coordinate of PDAF pixel blocks
158 * @main_offset_y: Start Y coordinate of PDAF pixel blocks
159 * @global_pdaf_type: PDAF pattern type
160 * @block_width: Width of a block in pixels
161 * @block_height: Heigth of a block in pixels
162 * @num_block_desc_groups: Number of block descriptor groups
163 * @block_desc_groups: Block descriptor groups
164 * @num_pixel_desc_grups: Number of pixel descriptor groups
165 * @pixel_desc_groups: Pixel descriptor groups
167 struct ccs_pdaf_pix_loc {
168 u16 main_offset_x;
169 u16 main_offset_y;
170 u8 global_pdaf_type;
171 u8 block_width;
172 u8 block_height;
173 u16 num_block_desc_groups;
174 struct ccs_pdaf_pix_loc_block_desc_group *block_desc_groups;
175 u8 num_pixel_desc_grups;
176 struct ccs_pdaf_pix_loc_pixel_desc_group *pixel_desc_groups;
180 * struct ccs_data_container - In-memory CCS static data
181 * @version: CCS static data version
182 * @num_sensor_read_only_regs: Number of the read-only registers for the sensor
183 * @sensor_read_only_regs: Read-only registers for the sensor
184 * @num_sensor_manufacturer_regs: Number of the manufacturer-specific registers
185 * for the sensor
186 * @sensor_manufacturer_regs: Manufacturer-specific registers for the sensor
187 * @num_sensor_rules: Number of rules for the sensor
188 * @sensor_rules: Rules for the sensor
189 * @num_module_read_only_regs: Number of the read-only registers for the module
190 * @module_read_only_regs: Read-only registers for the module
191 * @num_module_manufacturer_regs: Number of the manufacturer-specific registers
192 * for the module
193 * @module_manufacturer_regs: Manufacturer-specific registers for the module
194 * @num_module_rules: Number of rules for the module
195 * @module_rules: Rules for the module
196 * @sensor_pdaf: PDAF data for the sensor
197 * @module_pdaf: PDAF data for the module
198 * @license_length: Lenght of the license data
199 * @license: License data
200 * @end: Whether or not there's an end block
201 * @backing: Raw data, pointed to from elsewhere so keep it around
203 struct ccs_data_container {
204 struct ccs_data_block_version *version;
205 size_t num_sensor_read_only_regs;
206 struct ccs_reg *sensor_read_only_regs;
207 size_t num_sensor_manufacturer_regs;
208 struct ccs_reg *sensor_manufacturer_regs;
209 size_t num_sensor_rules;
210 struct ccs_rule *sensor_rules;
211 size_t num_module_read_only_regs;
212 struct ccs_reg *module_read_only_regs;
213 size_t num_module_manufacturer_regs;
214 struct ccs_reg *module_manufacturer_regs;
215 size_t num_module_rules;
216 struct ccs_rule *module_rules;
217 struct ccs_pdaf_pix_loc *sensor_pdaf;
218 struct ccs_pdaf_pix_loc *module_pdaf;
219 size_t license_length;
220 char *license;
221 bool end;
222 void *backing;
225 int ccs_data_parse(struct ccs_data_container *ccsdata, const void *data,
226 size_t len, struct device *dev, bool verbose);
228 #endif /* __CCS_DATA_H__ */