libctru  v1.6.0
y2r.h
Go to the documentation of this file.
1 /**
2  * @file y2r.h
3  * @brief Y2R service for hardware YUV->RGB conversions
4  */
5 #pragma once
6 #include <3ds/types.h>
7 
8 /**
9  * @brief Input color formats
10  *
11  * For the 16-bit per component formats, bits 15-8 are padding and 7-0 contains the value.
12  */
13 typedef enum
14 {
15  INPUT_YUV422_INDIV_8 = 0x0, ///< 8-bit per component, planar YUV 4:2:2, 16bpp, (1 Cr & Cb sample per 2x1 Y samples).\n Usually named YUV422P.
16  INPUT_YUV420_INDIV_8 = 0x1, ///< 8-bit per component, planar YUV 4:2:0, 12bpp, (1 Cr & Cb sample per 2x2 Y samples).\n Usually named YUV420P.
17  INPUT_YUV422_INDIV_16 = 0x2, ///< 16-bit per component, planar YUV 4:2:2, 32bpp, (1 Cr & Cb sample per 2x1 Y samples).\n Usually named YUV422P16.
18  INPUT_YUV420_INDIV_16 = 0x3, ///< 16-bit per component, planar YUV 4:2:0, 24bpp, (1 Cr & Cb sample per 2x2 Y samples).\n Usually named YUV420P16.
19  INPUT_YUV422_BATCH = 0x4, ///< 8-bit per component, packed YUV 4:2:2, 16bpp, (Y0 Cb Y1 Cr).\n Usually named YUYV422.
21 
22 /**
23  * @brief Output color formats
24  *
25  * Those are the same as the framebuffer and GPU texture formats.
26  */
27 typedef enum
28 {
29  OUTPUT_RGB_32 = 0x0, ///< 32-bit RGBA8888. The alpha component is the 8-bit value set by @ref Y2RU_SetAlpha
30  OUTPUT_RGB_24 = 0x1, ///< 24-bit RGB888.
31  OUTPUT_RGB_16_555 = 0x2, ///< 16-bit RGBA5551. The alpha bit is the 7th bit of the alpha value set by @ref Y2RU_SetAlpha
32  OUTPUT_RGB_16_565 = 0x3, ///< 16-bit RGB565.
34 
35 /// Rotation to be applied to the output.
36 typedef enum
37 {
38  ROTATION_NONE = 0x0, ///< No rotation.
39  ROTATION_CLOCKWISE_90 = 0x1, ///< Clockwise 90 degrees.
40  ROTATION_CLOCKWISE_180 = 0x2, ///< Clockwise 180 degrees.
41  ROTATION_CLOCKWISE_270 = 0x3, ///< Clockwise 270 degrees.
43 
44 /**
45  * @brief Block alignment of output
46  *
47  * Defines the way the output will be laid out in memory.
48  */
49 typedef enum
50 {
51  BLOCK_LINE = 0x0, ///< The result buffer will be laid out in linear format, the usual way.
52  BLOCK_8_BY_8 = 0x1, ///< The result will be stored as 8x8 blocks in Z-order.\n Useful for textures since it is the format used by the PICA200.
54 
55 /**
56  * @brief Coefficients of the YUV->RGB conversion formula.
57  *
58  * A set of coefficients configuring the RGB to YUV conversion. Coefficients 0-4 are unsigned 2.8
59  * fixed pointer numbers representing entries on the conversion matrix, while coefficient 5-7 are
60  * signed 11.5 fixed point numbers added as offsets to the RGB result.
61  *
62  * The overall conversion process formula is:
63  * @code
64  * R = trunc((rgb_Y * Y + r_V * V) + 0.75 + r_offset)
65  * G = trunc((rgb_Y * Y - g_U * U - g_V * V) + 0.75 + g_offset)
66  * B = trunc((rgb_Y * Y + b_U * U ) + 0.75 + b_offset)
67  * @endcode
68  */
69 typedef struct
70 {
71  u16 rgb_Y; ///< RGB per unit Y.
72  u16 r_V; ///< Red per unit V.
73  u16 g_V; ///< Green per unit V.
74  u16 g_U; ///< Green per unit U.
75  u16 b_U; ///< Blue per unit U.
76  u16 r_offset; ///< Red offset.
77  u16 g_offset; ///< Green offset.
78  u16 b_offset; ///< Blue offset.
80 
81 /**
82  * @brief Preset conversion coefficients based on ITU standards for the YUV->RGB formula.
83  *
84  * For more details refer to @ref Y2RU_ColorCoefficients
85  */
86 typedef enum
87 {
88  COEFFICIENT_ITU_R_BT_601 = 0x0, ///< Coefficients from the ITU-R BT.601 standard with PC ranges.
89  COEFFICIENT_ITU_R_BT_709 = 0x1, ///< Coefficients from the ITU-R BT.709 standard with PC ranges.
90  COEFFICIENT_ITU_R_BT_601_SCALING = 0x2, ///< Coefficients from the ITU-R BT.601 standard with TV ranges.
91  COEFFICIENT_ITU_R_BT_709_SCALING = 0x3, ///< Coefficients from the ITU-R BT.709 standard with TV ranges.
93 
94 /**
95  * @brief Structure used to configure all parameters at once.
96  *
97  * You can send a batch of configuration parameters using this structure and @ref Y2RU_SetConversionParams.
98  */
99 typedef struct
100 {
101  Y2RU_InputFormat input_format : 8; ///< Value passed to @ref Y2RU_SetInputFormat
102  Y2RU_OutputFormat output_format : 8; ///< Value passed to @ref Y2RU_SetOutputFormat
103  Y2RU_Rotation rotation : 8; ///< Value passed to @ref Y2RU_SetRotation
104  Y2RU_BlockAlignment block_alignment : 8; ///< Value passed to @ref Y2RU_SetBlockAlignment
105  s16 input_line_width; ///< Value passed to @ref Y2RU_SetInputLineWidth
106  s16 input_lines; ///< Value passed to @ref Y2RU_SetInputLines
107  Y2RU_StandardCoefficient standard_coefficient : 8; ///< Value passed to @ref Y2RU_SetStandardCoefficient
108  u8 unused; ///< Unused.
109  u16 alpha; ///< Value passed to @ref Y2RU_SetAlpha
111 
112 /// Dithering weights.
113 typedef struct
114 {
115  u16 w0_xEven_yEven; ///< Weight 0 for even X, even Y.
116  u16 w0_xOdd_yEven; ///< Weight 0 for odd X, even Y.
117  u16 w0_xEven_yOdd; ///< Weight 0 for even X, odd Y.
118  u16 w0_xOdd_yOdd; ///< Weight 0 for odd X, odd Y.
119  u16 w1_xEven_yEven; ///< Weight 1 for even X, even Y.
120  u16 w1_xOdd_yEven; ///< Weight 1 for odd X, even Y.
121  u16 w1_xEven_yOdd; ///< Weight 1 for even X, odd Y.
122  u16 w1_xOdd_yOdd; ///< Weight 1 for odd X, odd Y.
123  u16 w2_xEven_yEven; ///< Weight 2 for even X, even Y.
124  u16 w2_xOdd_yEven; ///< Weight 2 for odd X, even Y.
125  u16 w2_xEven_yOdd; ///< Weight 2 for even X, odd Y.
126  u16 w2_xOdd_yOdd; ///< Weight 2 for odd X, odd Y.
127  u16 w3_xEven_yEven; ///< Weight 3 for even X, even Y.
128  u16 w3_xOdd_yEven; ///< Weight 3 for odd X, even Y.
129  u16 w3_xEven_yOdd; ///< Weight 3 for even X, odd Y.
130  u16 w3_xOdd_yOdd; ///< Weight 3 for odd X, odd Y.
132 
133 /**
134  * @brief Initializes the y2r service.
135  *
136  * This will internally get the handle of the service, and on success call Y2RU_DriverInitialize.
137  */
138 Result y2rInit(void);
139 
140 /**
141  * @brief Closes the y2r service.
142  *
143  * This will internally call Y2RU_DriverFinalize and close the handle of the service.
144  */
145 void y2rExit(void);
146 
147 /**
148  * @brief Used to configure the input format.
149  * @param format Input format to use.
150  *
151  * @note Prefer using @ref Y2RU_SetConversionParams if you have to set multiple parameters.
152  */
154 
155 /**
156  * @brief Gets the configured input format.
157  * @param format Pointer to output the input format to.
158  */
160 
161 /**
162  * @brief Used to configure the output format.
163  * @param format Output format to use.
164  *
165  * @note Prefer using @ref Y2RU_SetConversionParams if you have to set multiple parameters.
166  */
168 
169 /**
170  * @brief Gets the configured output format.
171  * @param format Pointer to output the output format to.
172  */
174 
175 /**
176  * @brief Used to configure the rotation of the output.
177  * @param rotation Rotation to use.
178  *
179  * It seems to apply the rotation per batch of 8 lines, so the output will be (height/8) images of size 8 x width.
180  *
181  * @note Prefer using @ref Y2RU_SetConversionParams if you have to set multiple parameters.
182  */
184 
185 /**
186  * @brief Gets the configured rotation.
187  * @param rotation Pointer to output the rotation to.
188  */
190 
191 /**
192  * @brief Used to configure the alignment of the output buffer.
193  * @param alignment Alignment to use.
194  *
195  * @note Prefer using @ref Y2RU_SetConversionParams if you have to set multiple parameters.
196  */
198 
199 /**
200  * @brief Gets the configured alignment.
201  * @param alignment Pointer to output the alignment to.
202  */
204 
205 /**
206  * @brief Sets whether to use spacial dithering.
207  * @param enable Whether to use spacial dithering.
208  */
209 Result Y2RU_SetSpacialDithering(bool enable);
210 
211 /**
212  * @brief Gets whether to use spacial dithering.
213  * @param enable Pointer to output the spacial dithering state to.
214  */
215 Result Y2RU_GetSpacialDithering(bool* enabled);
216 
217 /**
218  * @brief Sets whether to use temporal dithering.
219  * @param enable Whether to use temporal dithering.
220  */
221 Result Y2RU_SetTemporalDithering(bool enable);
222 
223 /**
224  * @brief Gets whether to use temporal dithering.
225  * @param enable Pointer to output the temporal dithering state to.
226  */
227 Result Y2RU_GetTemporalDithering(bool* enabled);
228 
229 
230 /**
231  * @brief Used to configure the width of the image.
232  * @param line_width Width of the image in pixels. Must be a multiple of 8, up to 1024.
233  *
234  * @note Prefer using @ref Y2RU_SetConversionParams if you have to set multiple parameters.
235  */
236 Result Y2RU_SetInputLineWidth(u16 line_width);
237 
238 /**
239  * @brief Gets the configured input line width.
240  * @param line_width Pointer to output the line width to.
241  */
242 Result Y2RU_GetInputLineWidth(u16* line_width);
243 
244 /**
245  * @brief Used to configure the height of the image.
246  * @param num_lines Number of lines to be converted.
247  *
248  * A multiple of 8 seems to be preferred.
249  * If using the @ref BLOCK_8_BY_8 mode, it must be a multiple of 8.
250  *
251  * @note Prefer using @ref Y2RU_SetConversionParams if you have to set multiple parameters.
252  */
253 Result Y2RU_SetInputLines(u16 num_lines);
254 
255 /**
256  * @brief Gets the configured number of input lines.
257  * @param num_lines Pointer to output the input lines to.
258  */
259 Result Y2RU_GetInputLines(u16* num_lines);
260 
261 /**
262  * @brief Used to configure the color conversion formula.
263  * @param coefficients Coefficients to use.
264  *
265  * See @ref Y2RU_ColorCoefficients for more information about the coefficients.
266  *
267  * @note Prefer using @ref Y2RU_SetConversionParams if you have to set multiple parameters.
268  */
270 
271 /**
272  * @brief Gets the configured color coefficients.
273  * @param num_lines Pointer to output the coefficients to.
274  */
276 
277 /**
278  * @brief Used to configure the color conversion formula with ITU stantards coefficients.
279  * @param coefficient Standard coefficient to use.
280  *
281  * See @ref Y2RU_ColorCoefficients for more information about the coefficients.
282  *
283  * @note Prefer using @ref Y2RU_SetConversionParams if you have to set multiple parameters.
284  */
286 
287 /**
288  * @brief Gets the color coefficient parameters of a standard coefficient.
289  * @param coefficients Pointer to output the coefficients to.
290  * @param standardCoeff Standard coefficient to check.
291  */
293 
294 /**
295  * @brief Used to configure the alpha value of the output.
296  * @param alpha 8-bit value to be used for the output when the format requires it.
297  *
298  * @note Prefer using @ref Y2RU_SetConversionParams if you have to set multiple parameters.
299  */
300 Result Y2RU_SetAlpha(u16 alpha);
301 
302 /**
303  * @brief Gets the configured output alpha value.
304  * @param alpha Pointer to output the alpha value to.
305  */
306 Result Y2RU_GetAlpha(u16* alpha);
307 
308 /**
309  * @brief Used to enable the end of conversion interrupt.
310  * @param should_interrupt Enables the interrupt if true, disable it if false.
311  *
312  * It is possible to fire an interrupt when the conversion is finished, and that the DMA is done copying the data.
313  * This interrupt will then be used to fire an event. See @ref Y2RU_GetTransferEndEvent.
314  * By default the interrupt is enabled.
315  *
316  * @note It seems that the event can be fired too soon in some cases, depending the transfer_unit size.\n Please see the note at @ref Y2RU_SetReceiving
317  */
318 Result Y2RU_SetTransferEndInterrupt(bool should_interrupt);
319 
320 /**
321  * @brief Gets whether the transfer end interrupt is enabled.
322  * @param should_interrupt Pointer to output the interrupt state to.
323  */
324 Result Y2RU_GetTransferEndInterrupt(bool* should_interrupt);
325 
326 /**
327  * @brief Gets an handle to the end of conversion event.
328  * @param end_event Pointer to the event handle to be set to the end of conversion event. It isn't necessary to create or close this handle.
329  *
330  * To enable this event you have to use @code{C} Y2RU_SetTransferEndInterrupt(true);@endcode
331  * The event will be triggered when the corresponding interrupt is fired.
332  *
333  * @note It is recommended to use a timeout when waiting on this event, as it sometimes (but rarely) isn't triggered.
334  */
336 
337 /**
338  * @brief Configures the Y plane buffer.
339  * @param src_buf A pointer to the beginning of your Y data buffer.
340  * @param image_size The total size of the data buffer.
341  * @param transfer_unit Specifies the size of 1 DMA transfer. Usually set to 1 line. This has to be a divisor of image_size.
342  * @param transfer_gap Specifies the gap (offset) to be added after each transfer. Can be used to convert images with stride or only a part of it.
343  *
344  * @warning transfer_unit+transfer_gap must be less than 32768 (0x8000)
345  *
346  * This specifies the Y data buffer for the planar input formats (INPUT_YUV42*_INDIV_*).
347  * The actual transfer will only happen after calling @ref Y2RU_StartConversion.
348  */
349 Result Y2RU_SetSendingY(const void* src_buf, u32 image_size, s16 transfer_unit, s16 transfer_gap);
350 
351 /**
352  * @brief Configures the U plane buffer.
353  * @param src_buf A pointer to the beginning of your Y data buffer.
354  * @param image_size The total size of the data buffer.
355  * @param transfer_unit Specifies the size of 1 DMA transfer. Usually set to 1 line. This has to be a divisor of image_size.
356  * @param transfer_gap Specifies the gap (offset) to be added after each transfer. Can be used to convert images with stride or only a part of it.
357  *
358  * @warning transfer_unit+transfer_gap must be less than 32768 (0x8000)
359  *
360  * This specifies the U data buffer for the planar input formats (INPUT_YUV42*_INDIV_*).
361  * The actual transfer will only happen after calling @ref Y2RU_StartConversion.
362  */
363 Result Y2RU_SetSendingU(const void* src_buf, u32 image_size, s16 transfer_unit, s16 transfer_gap);
364 
365 /**
366  * @brief Configures the V plane buffer.
367  * @param src_buf A pointer to the beginning of your Y data buffer.
368  * @param image_size The total size of the data buffer.
369  * @param transfer_unit Specifies the size of 1 DMA transfer. Usually set to 1 line. This has to be a divisor of image_size.
370  * @param transfer_gap Specifies the gap (offset) to be added after each transfer. Can be used to convert images with stride or only a part of it.
371  *
372  * @warning transfer_unit+transfer_gap must be less than 32768 (0x8000)
373  *
374  * This specifies the V data buffer for the planar input formats (INPUT_YUV42*_INDIV_*).
375  * The actual transfer will only happen after calling @ref Y2RU_StartConversion.
376  */
377 Result Y2RU_SetSendingV(const void* src_buf, u32 image_size, s16 transfer_unit, s16 transfer_gap);
378 
379 /**
380  * @brief Configures the YUYV source buffer.
381  * @param src_buf A pointer to the beginning of your Y data buffer.
382  * @param image_size The total size of the data buffer.
383  * @param transfer_unit Specifies the size of 1 DMA transfer. Usually set to 1 line. This has to be a divisor of image_size.
384  * @param transfer_gap Specifies the gap (offset) to be added after each transfer. Can be used to convert images with stride or only a part of it.
385  *
386  * @warning transfer_unit+transfer_gap must be less than 32768 (0x8000)
387  *
388  * This specifies the YUYV data buffer for the packed input format @ref INPUT_YUV422_BATCH.
389  * The actual transfer will only happen after calling @ref Y2RU_StartConversion.
390  */
391 Result Y2RU_SetSendingYUYV(const void* src_buf, u32 image_size, s16 transfer_unit, s16 transfer_gap);
392 
393 /**
394  * @brief Configures the destination buffer.
395  * @param src_buf A pointer to the beginning of your destination buffer in FCRAM
396  * @param image_size The total size of the data buffer.
397  * @param transfer_unit Specifies the size of 1 DMA transfer. Usually set to 1 line. This has to be a divisor of image_size.
398  * @param transfer_gap Specifies the gap (offset) to be added after each transfer. Can be used to convert images with stride or only a part of it.
399  *
400  * This specifies the destination buffer of the conversion.
401  * The actual transfer will only happen after calling @ref Y2RU_StartConversion.
402  * The buffer does NOT need to be allocated in the linear heap.
403  *
404  * @warning transfer_unit+transfer_gap must be less than 32768 (0x8000)
405  *
406  * @note
407  * It seems that depending on the size of the image and of the transfer unit,\n
408  * it is possible for the end of conversion interrupt to be triggered right after the conversion began.\n
409  * One line as transfer_unit seems to trigger this issue for 400x240, setting to 2/4/8 lines fixes it.
410  *
411  * @note Setting a transfer_unit of 4 or 8 lines seems to bring the best results in terms of speed for a 400x240 image.
412  */
413 Result Y2RU_SetReceiving(void* dst_buf, u32 image_size, s16 transfer_unit, s16 transfer_gap);
414 
415 /**
416  * @brief Checks if the DMA has finished sending the Y buffer.
417  * @param is_done Pointer to the boolean that will hold the result.
418  *
419  * True if the DMA has finished transferring the Y plane, false otherwise. To be used with @ref Y2RU_SetSendingY.
420  */
421 Result Y2RU_IsDoneSendingY(bool* is_done);
422 
423 /**
424  * @brief Checks if the DMA has finished sending the U buffer.
425  * @param is_done Pointer to the boolean that will hold the result.
426  *
427  * True if the DMA has finished transferring the U plane, false otherwise. To be used with @ref Y2RU_SetSendingU.
428  */
429 Result Y2RU_IsDoneSendingU(bool* is_done);
430 
431 /**
432  * @brief Checks if the DMA has finished sending the V buffer.
433  * @param is_done Pointer to the boolean that will hold the result.
434  *
435  * True if the DMA has finished transferring the V plane, false otherwise. To be used with @ref Y2RU_SetSendingV.
436  */
437 Result Y2RU_IsDoneSendingV(bool* is_done);
438 
439 /**
440  * @brief Checks if the DMA has finished sending the YUYV buffer.
441  * @param is_done Pointer to the boolean that will hold the result.
442  *
443  * True if the DMA has finished transferring the YUYV buffer, false otherwise. To be used with @ref Y2RU_SetSendingYUYV.
444  */
445 Result Y2RU_IsDoneSendingYUYV(bool* is_done);
446 
447 /**
448  * @brief Checks if the DMA has finished sending the converted result.
449  * @param is_done Pointer to the boolean that will hold the result.
450  *
451  * True if the DMA has finished transferring data to your destination buffer, false otherwise.
452  */
453 Result Y2RU_IsDoneReceiving(bool* is_done);
454 
455 /**
456  * @brief Configures the dithering weight parameters.
457  * @param params Dithering weight parameters to use.
458  */
460 
461 /**
462  * @brief Gets the configured dithering weight parameters.
463  * @param params Pointer to output the dithering weight parameters to.
464  */
466 
467 /**
468  * @brief Sets all of the parameters of Y2RU_ConversionParams at once.
469  * @param params Conversion parameters to set.
470  *
471  * Faster than calling the individual value through Y2R_Set* because only one system call is made.
472  */
474 
475 /// Starts the conversion process
477 
478 /// Cancels the conversion
480 
481 /**
482  * @brief Checks if the conversion and DMA transfer are finished.
483  * @param is_busy Pointer to output the busy state to.
484  *
485  * This can have the same problems as the event and interrupt. See @ref Y2RU_SetTransferEndInterrupt.
486  */
487 Result Y2RU_IsBusyConversion(bool* is_busy);
488 
489 /**
490  * @brief Checks whether Y2R is ready to be used.
491  * @param ping Pointer to output the ready status to.
492  */
493 Result Y2RU_PingProcess(u8* ping);
494 
495 /// Initializes the Y2R driver.
497 
498 /// Terminates the Y2R driver.
500 
Result Y2RU_IsDoneSendingU(bool *is_done)
Checks if the DMA has finished sending the U buffer.
Result Y2RU_IsDoneReceiving(bool *is_done)
Checks if the DMA has finished sending the converted result.
u16 w2_xOdd_yOdd
Weight 2 for odd X, odd Y.
Definition: y2r.h:126
Structure used to configure all parameters at once.
Definition: y2r.h:99
Result Y2RU_PingProcess(u8 *ping)
Checks whether Y2R is ready to be used.
16-bit per component, planar YUV 4:2:2, 32bpp, (1 Cr & Cb sample per 2x1 Y samples)....
Definition: y2r.h:17
u16 w2_xEven_yOdd
Weight 2 for even X, odd Y.
Definition: y2r.h:125
Various system types.
Result Y2RU_GetSpacialDithering(bool *enabled)
Gets whether to use spacial dithering.
s32 Result
Function result.
Definition: types.h:42
u16 w1_xEven_yEven
Weight 1 for even X, even Y.
Definition: y2r.h:119
Y2RU_OutputFormat output_format
Value passed to Y2RU_SetOutputFormat.
Definition: y2r.h:102
u16 w2_xEven_yEven
Weight 2 for even X, even Y.
Definition: y2r.h:123
Result Y2RU_GetRotation(Y2RU_Rotation *rotation)
Gets the configured rotation.
u16 w1_xOdd_yOdd
Weight 1 for odd X, odd Y.
Definition: y2r.h:122
uint16_t u16
16-bit unsigned integer
Definition: types.h:22
u16 b_U
Blue per unit U.
Definition: y2r.h:75
Result Y2RU_GetCoefficients(Y2RU_ColorCoefficients *coefficients)
Gets the configured color coefficients.
32-bit RGBA8888. The alpha component is the 8-bit value set by Y2RU_SetAlpha
Definition: y2r.h:29
Result Y2RU_SetBlockAlignment(Y2RU_BlockAlignment alignment)
Used to configure the alignment of the output buffer.
u16 g_V
Green per unit V.
Definition: y2r.h:73
u8 unused
Unused.
Definition: y2r.h:108
Result Y2RU_GetStandardCoefficient(Y2RU_ColorCoefficients *coefficients, Y2RU_StandardCoefficient standardCoeff)
Gets the color coefficient parameters of a standard coefficient.
Coefficients from the ITU-R BT.601 standard with TV ranges.
Definition: y2r.h:90
Result y2rInit(void)
Initializes the y2r service.
No rotation.
Definition: y2r.h:38
Result Y2RU_IsDoneSendingV(bool *is_done)
Checks if the DMA has finished sending the V buffer.
Y2RU_InputFormat
Input color formats.
Definition: y2r.h:13
Result Y2RU_SetInputLineWidth(u16 line_width)
Used to configure the width of the image.
Result Y2RU_SetConversionParams(const Y2RU_ConversionParams *params)
Sets all of the parameters of Y2RU_ConversionParams at once.
s16 input_line_width
Value passed to Y2RU_SetInputLineWidth.
Definition: y2r.h:105
Result Y2RU_GetDitheringWeightParams(Y2RU_DitheringWeightParams *params)
Gets the configured dithering weight parameters.
u32 Handle
Resource handle.
Definition: types.h:41
u16 w3_xEven_yEven
Weight 3 for even X, even Y.
Definition: y2r.h:127
Coefficients from the ITU-R BT.601 standard with PC ranges.
Definition: y2r.h:88
Result Y2RU_GetAlpha(u16 *alpha)
Gets the configured output alpha value.
u16 w1_xEven_yOdd
Weight 1 for even X, odd Y.
Definition: y2r.h:121
uint8_t u8
would be nice if newlib had this already
Definition: types.h:21
u16 w1_xOdd_yEven
Weight 1 for odd X, even Y.
Definition: y2r.h:120
Result Y2RU_SetSpacialDithering(bool enable)
Sets whether to use spacial dithering.
u16 w3_xOdd_yOdd
Weight 3 for odd X, odd Y.
Definition: y2r.h:130
u16 alpha
Value passed to Y2RU_SetAlpha.
Definition: y2r.h:109
Result Y2RU_SetSendingY(const void *src_buf, u32 image_size, s16 transfer_unit, s16 transfer_gap)
Configures the Y plane buffer.
Result Y2RU_SetInputLines(u16 num_lines)
Used to configure the height of the image.
Result Y2RU_SetTemporalDithering(bool enable)
Sets whether to use temporal dithering.
Result Y2RU_GetTransferEndEvent(Handle *end_event)
Gets an handle to the end of conversion event.
uint32_t u32
32-bit unsigned integer
Definition: types.h:23
Result Y2RU_SetTransferEndInterrupt(bool should_interrupt)
Used to enable the end of conversion interrupt.
Result Y2RU_GetInputLines(u16 *num_lines)
Gets the configured number of input lines.
Result Y2RU_SetReceiving(void *dst_buf, u32 image_size, s16 transfer_unit, s16 transfer_gap)
Configures the destination buffer.
u16 w0_xEven_yEven
Weight 0 for even X, even Y.
Definition: y2r.h:115
Result Y2RU_SetCoefficients(const Y2RU_ColorCoefficients *coefficients)
Used to configure the color conversion formula.
Result Y2RU_GetTransferEndInterrupt(bool *should_interrupt)
Gets whether the transfer end interrupt is enabled.
The result buffer will be laid out in linear format, the usual way.
Definition: y2r.h:51
Result Y2RU_SetOutputFormat(Y2RU_OutputFormat format)
Used to configure the output format.
The result will be stored as 8x8 blocks in Z-order. Useful for textures since it is the format used ...
Definition: y2r.h:52
Clockwise 270 degrees.
Definition: y2r.h:41
u16 w2_xOdd_yEven
Weight 2 for odd X, even Y.
Definition: y2r.h:124
u16 r_V
Red per unit V.
Definition: y2r.h:72
8-bit per component, packed YUV 4:2:2, 16bpp, (Y0 Cb Y1 Cr). Usually named YUYV422.
Definition: y2r.h:19
u16 g_U
Green per unit U.
Definition: y2r.h:74
Result Y2RU_SetSendingV(const void *src_buf, u32 image_size, s16 transfer_unit, s16 transfer_gap)
Configures the V plane buffer.
Result Y2RU_SetSendingU(const void *src_buf, u32 image_size, s16 transfer_unit, s16 transfer_gap)
Configures the U plane buffer.
Result Y2RU_GetOutputFormat(Y2RU_OutputFormat *format)
Gets the configured output format.
Y2RU_BlockAlignment
Block alignment of output.
Definition: y2r.h:49
Result Y2RU_SetStandardCoefficient(Y2RU_StandardCoefficient coefficient)
Used to configure the color conversion formula with ITU stantards coefficients.
u16 w3_xEven_yOdd
Weight 3 for even X, odd Y.
Definition: y2r.h:129
Result Y2RU_SetRotation(Y2RU_Rotation rotation)
Used to configure the rotation of the output.
Y2RU_StandardCoefficient standard_coefficient
Value passed to Y2RU_SetStandardCoefficient.
Definition: y2r.h:107
Result Y2RU_GetInputLineWidth(u16 *line_width)
Gets the configured input line width.
Result Y2RU_SetAlpha(u16 alpha)
Used to configure the alpha value of the output.
u16 w3_xOdd_yEven
Weight 3 for odd X, even Y.
Definition: y2r.h:128
Coefficients of the YUV->RGB conversion formula.
Definition: y2r.h:69
Y2RU_InputFormat input_format
Value passed to Y2RU_SetInputFormat.
Definition: y2r.h:101
u16 r_offset
Red offset.
Definition: y2r.h:76
Result Y2RU_IsDoneSendingYUYV(bool *is_done)
Checks if the DMA has finished sending the YUYV buffer.
Y2RU_OutputFormat
Output color formats.
Definition: y2r.h:27
Result Y2RU_IsDoneSendingY(bool *is_done)
Checks if the DMA has finished sending the Y buffer.
24-bit RGB888.
Definition: y2r.h:30
Coefficients from the ITU-R BT.709 standard with PC ranges.
Definition: y2r.h:89
Result Y2RU_SetSendingYUYV(const void *src_buf, u32 image_size, s16 transfer_unit, s16 transfer_gap)
Configures the YUYV source buffer.
u16 w0_xOdd_yOdd
Weight 0 for odd X, odd Y.
Definition: y2r.h:118
Result Y2RU_SetDitheringWeightParams(const Y2RU_DitheringWeightParams *params)
Configures the dithering weight parameters.
Result Y2RU_IsBusyConversion(bool *is_busy)
Checks if the conversion and DMA transfer are finished.
16-bit per component, planar YUV 4:2:0, 24bpp, (1 Cr & Cb sample per 2x2 Y samples)....
Definition: y2r.h:18
u16 b_offset
Blue offset.
Definition: y2r.h:78
Y2RU_Rotation
Rotation to be applied to the output.
Definition: y2r.h:36
Clockwise 180 degrees.
Definition: y2r.h:40
Result Y2RU_GetInputFormat(Y2RU_InputFormat *format)
Gets the configured input format.
Result Y2RU_StopConversion(void)
Cancels the conversion.
Result Y2RU_SetInputFormat(Y2RU_InputFormat format)
Used to configure the input format.
8-bit per component, planar YUV 4:2:2, 16bpp, (1 Cr & Cb sample per 2x1 Y samples)....
Definition: y2r.h:15
Y2RU_StandardCoefficient
Preset conversion coefficients based on ITU standards for the YUV->RGB formula.
Definition: y2r.h:86
16-bit RGBA5551. The alpha bit is the 7th bit of the alpha value set by Y2RU_SetAlpha
Definition: y2r.h:31
void y2rExit(void)
Closes the y2r service.
u16 w0_xOdd_yEven
Weight 0 for odd X, even Y.
Definition: y2r.h:116
16-bit RGB565.
Definition: y2r.h:32
Result Y2RU_DriverInitialize(void)
Initializes the Y2R driver.
u16 w0_xEven_yOdd
Weight 0 for even X, odd Y.
Definition: y2r.h:117
Result Y2RU_GetTemporalDithering(bool *enabled)
Gets whether to use temporal dithering.
Result Y2RU_DriverFinalize(void)
Terminates the Y2R driver.
s16 input_lines
Value passed to Y2RU_SetInputLines.
Definition: y2r.h:106
Coefficients from the ITU-R BT.709 standard with TV ranges.
Definition: y2r.h:91
u16 rgb_Y
RGB per unit Y.
Definition: y2r.h:71
Result Y2RU_StartConversion(void)
Starts the conversion process.
u16 g_offset
Green offset.
Definition: y2r.h:77
Dithering weights.
Definition: y2r.h:113
Y2RU_Rotation rotation
Value passed to Y2RU_SetRotation.
Definition: y2r.h:103
Clockwise 90 degrees.
Definition: y2r.h:39
int16_t s16
16-bit signed integer
Definition: types.h:27
8-bit per component, planar YUV 4:2:0, 12bpp, (1 Cr & Cb sample per 2x2 Y samples)....
Definition: y2r.h:16
Y2RU_BlockAlignment block_alignment
Value passed to Y2RU_SetBlockAlignment.
Definition: y2r.h:104
Result Y2RU_GetBlockAlignment(Y2RU_BlockAlignment *alignment)
Gets the configured alignment.