1 /* SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause */
3 * CCS static data in-memory data structure definitions
5 * Copyright 2019--2020 Intel Corporation
11 #include <linux/types.h>
16 * struct ccs_data_block_version - CCS static data version
17 * @version_major: Major version number
18 * @version_minor: Minor version number
23 struct ccs_data_block_version
{
32 * struct ccs_reg - CCS register value
33 * @addr: The 16-bit address of the register
34 * @len: Length of the data
44 * struct ccs_if_rule - CCS static data if rule
45 * @addr: Register address
46 * @value: Register value
47 * @mask: Value applied to both actual register value and @value
56 * struct ccs_frame_format_desc - CCS frame format descriptor
57 * @pixelcode: The pixelcode; CCS_DATA_BLOCK_FFD_PIXELCODE_*
58 * @value: Value related to the pixelcode
60 struct ccs_frame_format_desc
{
66 * struct ccs_frame_format_descs - A series of CCS frame format descriptors
67 * @num_column_descs: Number of column descriptors
68 * @num_row_descs: Number of row descriptors
69 * @column_descs: Column descriptors
70 * @row_descs: Row descriptors
72 struct ccs_frame_format_descs
{
75 struct ccs_frame_format_desc
*column_descs
;
76 struct ccs_frame_format_desc
*row_descs
;
80 * struct ccs_pdaf_readout - CCS PDAF data readout descriptor
81 * @pdaf_readout_info_order: PDAF readout order
82 * @ffd: Frame format of PDAF data
84 struct ccs_pdaf_readout
{
85 u8 pdaf_readout_info_order
;
86 struct ccs_frame_format_descs
*ffd
;
90 * struct ccs_rule - A CCS static data rule
91 * @num_if_rules: Number of if rules
93 * @num_read_only_regs: Number of read-only registers
94 * @read_only_regs: Read-only registers
95 * @num_manufacturer_regs: Number of manufacturer-specific registers
96 * @manufacturer_regs: Manufacturer-specific registers
97 * @frame_format: Frame format
98 * @pdaf_readout: PDAF readout
102 struct ccs_if_rule
*if_rules
;
103 size_t num_read_only_regs
;
104 struct ccs_reg
*read_only_regs
;
105 size_t num_manufacturer_regs
;
106 struct ccs_reg
*manufacturer_regs
;
107 struct ccs_frame_format_descs
*frame_format
;
108 struct ccs_pdaf_readout
*pdaf_readout
;
112 * struct ccs_pdaf_pix_loc_block_desc - PDAF pixel location block descriptor
113 * @block_type_id: Block type identifier, from 0 to n
114 * @repeat_x: Number of times this block is repeated to right
116 struct ccs_pdaf_pix_loc_block_desc
{
122 * struct ccs_pdaf_pix_loc_block_desc_group - PDAF pixel location block
124 * @repeat_y: Number of times the group is repeated down
125 * @num_block_descs: Number of block descriptors in @block_descs
126 * @block_descs: Block descriptors
128 struct ccs_pdaf_pix_loc_block_desc_group
{
131 struct ccs_pdaf_pix_loc_block_desc
*block_descs
;
135 * struct ccs_pdaf_pix_loc_pixel_desc - PDAF pixel location block descriptor
136 * @pixel_type: Type of the pixel; CCS_DATA_PDAF_PIXEL_TYPE_*
137 * @small_offset_x: offset X coordinate
138 * @small_offset_y: offset Y coordinate
140 struct ccs_pdaf_pix_loc_pixel_desc
{
147 * struct ccs_pdaf_pix_loc_pixel_desc_group - PDAF pixel location pixel
149 * @num_descs: Number of descriptors in @descs
150 * @descs: PDAF pixel location pixel descriptors
152 struct ccs_pdaf_pix_loc_pixel_desc_group
{
154 struct ccs_pdaf_pix_loc_pixel_desc
*descs
;
158 * struct ccs_pdaf_pix_loc - PDAF pixel locations
159 * @main_offset_x: Start X coordinate of PDAF pixel blocks
160 * @main_offset_y: Start Y coordinate of PDAF pixel blocks
161 * @global_pdaf_type: PDAF pattern type
162 * @block_width: Width of a block in pixels
163 * @block_height: Heigth of a block in pixels
164 * @num_block_desc_groups: Number of block descriptor groups
165 * @block_desc_groups: Block descriptor groups
166 * @num_pixel_desc_grups: Number of pixel descriptor groups
167 * @pixel_desc_groups: Pixel descriptor groups
169 struct ccs_pdaf_pix_loc
{
175 u16 num_block_desc_groups
;
176 struct ccs_pdaf_pix_loc_block_desc_group
*block_desc_groups
;
177 u8 num_pixel_desc_grups
;
178 struct ccs_pdaf_pix_loc_pixel_desc_group
*pixel_desc_groups
;
182 * struct ccs_data_container - In-memory CCS static data
183 * @version: CCS static data version
184 * @num_sensor_read_only_regs: Number of the read-only registers for the sensor
185 * @sensor_read_only_regs: Read-only registers for the sensor
186 * @num_sensor_manufacturer_regs: Number of the manufacturer-specific registers
188 * @sensor_manufacturer_regs: Manufacturer-specific registers for the sensor
189 * @num_sensor_rules: Number of rules for the sensor
190 * @sensor_rules: Rules for the sensor
191 * @num_module_read_only_regs: Number of the read-only registers for the module
192 * @module_read_only_regs: Read-only registers for the module
193 * @num_module_manufacturer_regs: Number of the manufacturer-specific registers
195 * @module_manufacturer_regs: Manufacturer-specific registers for the module
196 * @num_module_rules: Number of rules for the module
197 * @module_rules: Rules for the module
198 * @sensor_pdaf: PDAF data for the sensor
199 * @module_pdaf: PDAF data for the module
200 * @license_length: Lenght of the license data
201 * @license: License data
202 * @end: Whether or not there's an end block
203 * @backing: Raw data, pointed to from elsewhere so keep it around
205 struct ccs_data_container
{
206 struct ccs_data_block_version
*version
;
207 size_t num_sensor_read_only_regs
;
208 struct ccs_reg
*sensor_read_only_regs
;
209 size_t num_sensor_manufacturer_regs
;
210 struct ccs_reg
*sensor_manufacturer_regs
;
211 size_t num_sensor_rules
;
212 struct ccs_rule
*sensor_rules
;
213 size_t num_module_read_only_regs
;
214 struct ccs_reg
*module_read_only_regs
;
215 size_t num_module_manufacturer_regs
;
216 struct ccs_reg
*module_manufacturer_regs
;
217 size_t num_module_rules
;
218 struct ccs_rule
*module_rules
;
219 struct ccs_pdaf_pix_loc
*sensor_pdaf
;
220 struct ccs_pdaf_pix_loc
*module_pdaf
;
221 size_t license_length
;
227 int ccs_data_parse(struct ccs_data_container
*ccsdata
, const void *data
,
228 size_t len
, struct device
*dev
, bool verbose
);
230 #endif /* __CCS_DATA_H__ */