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>
14 * struct ccs_data_block_version - CCS static data version
15 * @version_major: Major version number
16 * @version_minor: Minor version number
21 struct ccs_data_block_version
{
30 * struct ccs_reg - CCS register value
31 * @addr: The 16-bit address of the register
32 * @len: Length of the data
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
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
{
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
{
73 struct ccs_frame_format_desc
*column_descs
;
74 struct ccs_frame_format_desc
*row_descs
;
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
;
88 * struct ccs_rule - A CCS static data rule
89 * @num_if_rules: Number of 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
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
{
120 * struct ccs_pdaf_pix_loc_block_desc_group - PDAF pixel location block
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
{
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
{
145 * struct ccs_pdaf_pix_loc_pixel_desc_group - PDAF pixel location pixel
147 * @num_descs: Number of descriptors in @descs
148 * @descs: PDAF pixel location pixel descriptors
150 struct ccs_pdaf_pix_loc_pixel_desc_group
{
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
{
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
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
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
;
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__ */