1 /* SPDX-License-Identifier: GPL-2.0 */
2 /*
3  * Copyright (C) STMicroelectronics SA 2015
4  * Author: Hugues Fruchet <hugues.fruchet@st.com> for STMicroelectronics.
5  */
6 
7 #ifndef DELTA_MJPEG_FW_H
8 #define DELTA_MJPEG_FW_H
9 
10 /*
11  * struct jpeg_decoded_buffer_address_t
12  *
13  * defines the addresses where the decoded picture/additional
14  * info related to the block structures will be stored
15  *
16  * @display_luma_p:		address of the luma buffer
17  * @display_chroma_p:		address of the chroma buffer
18  */
19 struct jpeg_decoded_buffer_address_t {
20 	u32 luma_p;
21 	u32 chroma_p;
22 };
23 
24 /*
25  * struct jpeg_display_buffer_address_t
26  *
27  * defines the addresses (used by the Display Reconstruction block)
28  * where the pictures to be displayed will be stored
29  *
30  * @struct_size:		size of the structure in bytes
31  * @display_luma_p:		address of the luma buffer
32  * @display_chroma_p:		address of the chroma buffer
33  * @display_decimated_luma_p:	address of the decimated luma buffer
34  * @display_decimated_chroma_p:	address of the decimated chroma buffer
35  */
36 struct jpeg_display_buffer_address_t {
37 	u32 struct_size;
38 	u32 display_luma_p;
39 	u32 display_chroma_p;
40 	u32 display_decimated_luma_p;
41 	u32 display_decimated_chroma_p;
42 };
43 
44 /*
45  * used for enabling main/aux outputs for both display &
46  * reference reconstruction blocks
47  */
48 enum jpeg_rcn_ref_disp_enable_t {
49 	/* enable decimated (for display) reconstruction */
50 	JPEG_DISP_AUX_EN = 0x00000010,
51 	/* enable main (for display) reconstruction */
52 	JPEG_DISP_MAIN_EN = 0x00000020,
53 	/* enable both main & decimated (for display) reconstruction */
54 	JPEG_DISP_AUX_MAIN_EN = 0x00000030,
55 	/* enable only reference output(ex. for trick modes) */
56 	JPEG_REF_MAIN_EN = 0x00000100,
57 	/*
58 	 * enable reference output with decimated
59 	 * (for display) reconstruction
60 	 */
61 	JPEG_REF_MAIN_DISP_AUX_EN = 0x00000110,
62 	/*
63 	 * enable reference output with main
64 	 * (for display) reconstruction
65 	 */
66 	JPEG_REF_MAIN_DISP_MAIN_EN = 0x00000120,
67 	/*
68 	 * enable reference output with main & decimated
69 	 * (for display) reconstruction
70 	 */
71 	JPEG_REF_MAIN_DISP_MAIN_AUX_EN = 0x00000130
72 };
73 
74 /* identifies the horizontal decimation factor */
75 enum jpeg_horizontal_deci_factor_t {
76 	/* no resize */
77 	JPEG_HDEC_1 = 0x00000000,
78 	/* Advanced H/2 resize using improved 8-tap filters */
79 	JPEG_HDEC_ADVANCED_2 = 0x00000101,
80 	/* Advanced H/4 resize using improved 8-tap filters */
81 	JPEG_HDEC_ADVANCED_4 = 0x00000102
82 };
83 
84 /* identifies the vertical decimation factor */
85 enum jpeg_vertical_deci_factor_t {
86 	/* no resize */
87 	JPEG_VDEC_1 = 0x00000000,
88 	/* V/2 , progressive resize */
89 	JPEG_VDEC_ADVANCED_2_PROG = 0x00000204,
90 	/* V/2 , interlaced resize */
91 	JPEG_VDEC_ADVANCED_2_INT = 0x000000208
92 };
93 
94 /* status of the decoding process */
95 enum jpeg_decoding_error_t {
96 	JPEG_DECODER_NO_ERROR = 0,
97 	JPEG_DECODER_UNDEFINED_HUFF_TABLE = 1,
98 	JPEG_DECODER_UNSUPPORTED_MARKER = 2,
99 	JPEG_DECODER_UNABLE_ALLOCATE_MEMORY = 3,
100 	JPEG_DECODER_NON_SUPPORTED_SAMP_FACTORS = 4,
101 	JPEG_DECODER_BAD_PARAMETER = 5,
102 	JPEG_DECODER_DECODE_ERROR = 6,
103 	JPEG_DECODER_BAD_RESTART_MARKER = 7,
104 	JPEG_DECODER_UNSUPPORTED_COLORSPACE = 8,
105 	JPEG_DECODER_BAD_SOS_SPECTRAL = 9,
106 	JPEG_DECODER_BAD_SOS_SUCCESSIVE = 10,
107 	JPEG_DECODER_BAD_HEADER_LENGTH = 11,
108 	JPEG_DECODER_BAD_COUNT_VALUE = 12,
109 	JPEG_DECODER_BAD_DHT_MARKER = 13,
110 	JPEG_DECODER_BAD_INDEX_VALUE = 14,
111 	JPEG_DECODER_BAD_NUMBER_HUFFMAN_TABLES = 15,
112 	JPEG_DECODER_BAD_QUANT_TABLE_LENGTH = 16,
113 	JPEG_DECODER_BAD_NUMBER_QUANT_TABLES = 17,
114 	JPEG_DECODER_BAD_COMPONENT_COUNT = 18,
115 	JPEG_DECODER_DIVIDE_BY_ZERO_ERROR = 19,
116 	JPEG_DECODER_NOT_JPG_IMAGE = 20,
117 	JPEG_DECODER_UNSUPPORTED_ROTATION_ANGLE = 21,
118 	JPEG_DECODER_UNSUPPORTED_SCALING = 22,
119 	JPEG_DECODER_INSUFFICIENT_OUTPUTBUFFER_SIZE = 23,
120 	JPEG_DECODER_BAD_HWCFG_GP_VERSION_VALUE = 24,
121 	JPEG_DECODER_BAD_VALUE_FROM_RED = 25,
122 	JPEG_DECODER_BAD_SUBREGION_PARAMETERS = 26,
123 	JPEG_DECODER_PROGRESSIVE_DECODE_NOT_SUPPORTED = 27,
124 	JPEG_DECODER_ERROR_TASK_TIMEOUT = 28,
125 	JPEG_DECODER_ERROR_FEATURE_NOT_SUPPORTED = 29
126 };
127 
128 /* identifies the decoding mode */
129 enum jpeg_decoding_mode_t {
130 	JPEG_NORMAL_DECODE = 0,
131 };
132 
133 enum jpeg_additional_flags_t {
134 	JPEG_ADDITIONAL_FLAG_NONE = 0,
135 	/* request firmware to return values of the CEH registers */
136 	JPEG_ADDITIONAL_FLAG_CEH = 1,
137 	/* output storage of auxiliary reconstruction in Raster format. */
138 	JPEG_ADDITIONAL_FLAG_RASTER = 64,
139 	/* output storage of auxiliary reconstruction in 420MB format. */
140 	JPEG_ADDITIONAL_FLAG_420MB = 128
141 };
142 
143 /*
144  * struct jpeg_video_decode_init_params_t - initialization command parameters
145  *
146  * @circular_buffer_begin_addr_p:	start address of fw circular buffer
147  * @circular_buffer_end_addr_p:		end address of fw circular buffer
148  */
149 struct jpeg_video_decode_init_params_t {
150 	u32 circular_buffer_begin_addr_p;
151 	u32 circular_buffer_end_addr_p;
152 	u32 reserved;
153 };
154 
155 /*
156  * struct jpeg_decode_params_t - decode command parameters
157  *
158  * @picture_start_addr_p:	start address of jpeg picture
159  * @picture_end_addr_p:		end address of jpeg picture
160  * @decoded_buffer_addr:	decoded picture buffer
161  * @display_buffer_addr:	display picture buffer
162  * @main_aux_enable:		enable main and/or aux outputs
163  * @horizontal_decimation_factor:horizontal decimation factor
164  * @vertical_decimation_factor:	vertical decimation factor
165  * @xvalue0:			the x(0) coordinate for subregion decoding
166  * @xvalue1:			the x(1) coordinate for subregion decoding
167  * @yvalue0:			the y(0) coordinate for subregion decoding
168  * @yvalue1:			the y(1) coordinate for subregion decoding
169  * @decoding_mode:		decoding mode
170  * @additional_flags:		additional flags
171  * @field_flag:			determines frame/field scan
172  * @is_jpeg_image:		1 = still jpeg, 0 = motion jpeg
173  */
174 struct jpeg_decode_params_t {
175 	u32 picture_start_addr_p;
176 	u32 picture_end_addr_p;
177 	struct jpeg_decoded_buffer_address_t decoded_buffer_addr;
178 	struct jpeg_display_buffer_address_t display_buffer_addr;
179 	enum jpeg_rcn_ref_disp_enable_t main_aux_enable;
180 	enum jpeg_horizontal_deci_factor_t horizontal_decimation_factor;
181 	enum jpeg_vertical_deci_factor_t vertical_decimation_factor;
182 	u32 xvalue0;
183 	u32 xvalue1;
184 	u32 yvalue0;
185 	u32 yvalue1;
186 	enum jpeg_decoding_mode_t decoding_mode;
187 	u32 additional_flags;
188 	u32 field_flag;
189 	u32 reserved;
190 	u32 is_jpeg_image;
191 };
192 
193 /*
194  * struct jpeg_decode_return_params_t
195  *
196  * status returned by firmware after decoding
197  *
198  * @decode_time_in_us:	decoding time in microseconds
199  * @pm_cycles:		profiling information
200  * @pm_dmiss:		profiling information
201  * @pm_imiss:		profiling information
202  * @pm_bundles:		profiling information
203  * @pm_pft:		profiling information
204  * @error_code:		status of the decoding process
205  * @ceh_registers:	array where values of the Contrast Enhancement
206  *			Histogram (CEH) registers will be stored.
207  *			ceh_registers[0] correspond to register MBE_CEH_0_7,
208  *			ceh_registers[1] correspond to register MBE_CEH_8_15
209  *			ceh_registers[2] correspond to register MBE_CEH_16_23
210  *			Note that elements of this array will be updated only
211  *			if additional_flags has JPEG_ADDITIONAL_FLAG_CEH set.
212  */
213 struct jpeg_decode_return_params_t {
214 	/* profiling info */
215 	u32 decode_time_in_us;
216 	u32 pm_cycles;
217 	u32 pm_dmiss;
218 	u32 pm_imiss;
219 	u32 pm_bundles;
220 	u32 pm_pft;
221 	enum jpeg_decoding_error_t error_code;
222 	u32 ceh_registers[32];
223 };
224 
225 #endif /* DELTA_MJPEG_FW_H */
226