libctru
v2.4.1
|
Y2R service for hardware YUV->RGB conversions. More...
#include <3ds/types.h>
Go to the source code of this file.
Data Structures | |
struct | Y2RU_ColorCoefficients |
Coefficients of the YUV->RGB conversion formula. More... | |
struct | Y2RU_ConversionParams |
Structure used to configure all parameters at once. More... | |
struct | Y2RU_DitheringWeightParams |
Dithering weights. More... | |
Enumerations | |
enum | Y2RU_InputFormat { INPUT_YUV422_INDIV_8 = 0x0 , INPUT_YUV420_INDIV_8 = 0x1 , INPUT_YUV422_INDIV_16 = 0x2 , INPUT_YUV420_INDIV_16 = 0x3 , INPUT_YUV422_BATCH = 0x4 } |
Input color formats. More... | |
enum | Y2RU_OutputFormat { OUTPUT_RGB_32 = 0x0 , OUTPUT_RGB_24 = 0x1 , OUTPUT_RGB_16_555 = 0x2 , OUTPUT_RGB_16_565 = 0x3 } |
Output color formats. More... | |
enum | Y2RU_Rotation { ROTATION_NONE = 0x0 , ROTATION_CLOCKWISE_90 = 0x1 , ROTATION_CLOCKWISE_180 = 0x2 , ROTATION_CLOCKWISE_270 = 0x3 } |
Rotation to be applied to the output. More... | |
enum | Y2RU_BlockAlignment { BLOCK_LINE = 0x0 , BLOCK_8_BY_8 = 0x1 } |
Block alignment of output. More... | |
enum | Y2RU_StandardCoefficient { COEFFICIENT_ITU_R_BT_601 = 0x0 , COEFFICIENT_ITU_R_BT_709 = 0x1 , COEFFICIENT_ITU_R_BT_601_SCALING = 0x2 , COEFFICIENT_ITU_R_BT_709_SCALING = 0x3 } |
Preset conversion coefficients based on ITU standards for the YUV->RGB formula. More... | |
Functions | |
Result | y2rInit (void) |
Initializes the y2r service. More... | |
void | y2rExit (void) |
Closes the y2r service. More... | |
Result | Y2RU_SetInputFormat (Y2RU_InputFormat format) |
Used to configure the input format. More... | |
Result | Y2RU_GetInputFormat (Y2RU_InputFormat *format) |
Gets the configured input format. More... | |
Result | Y2RU_SetOutputFormat (Y2RU_OutputFormat format) |
Used to configure the output format. More... | |
Result | Y2RU_GetOutputFormat (Y2RU_OutputFormat *format) |
Gets the configured output format. More... | |
Result | Y2RU_SetRotation (Y2RU_Rotation rotation) |
Used to configure the rotation of the output. More... | |
Result | Y2RU_GetRotation (Y2RU_Rotation *rotation) |
Gets the configured rotation. More... | |
Result | Y2RU_SetBlockAlignment (Y2RU_BlockAlignment alignment) |
Used to configure the alignment of the output buffer. More... | |
Result | Y2RU_GetBlockAlignment (Y2RU_BlockAlignment *alignment) |
Gets the configured alignment. More... | |
Result | Y2RU_SetSpacialDithering (bool enable) |
Sets whether to use spacial dithering. More... | |
Result | Y2RU_GetSpacialDithering (bool *enabled) |
Gets whether to use spacial dithering. More... | |
Result | Y2RU_SetTemporalDithering (bool enable) |
Sets whether to use temporal dithering. More... | |
Result | Y2RU_GetTemporalDithering (bool *enabled) |
Gets whether to use temporal dithering. More... | |
Result | Y2RU_SetInputLineWidth (u16 line_width) |
Used to configure the width of the image. More... | |
Result | Y2RU_GetInputLineWidth (u16 *line_width) |
Gets the configured input line width. More... | |
Result | Y2RU_SetInputLines (u16 num_lines) |
Used to configure the height of the image. More... | |
Result | Y2RU_GetInputLines (u16 *num_lines) |
Gets the configured number of input lines. More... | |
Result | Y2RU_SetCoefficients (const Y2RU_ColorCoefficients *coefficients) |
Used to configure the color conversion formula. More... | |
Result | Y2RU_GetCoefficients (Y2RU_ColorCoefficients *coefficients) |
Gets the configured color coefficients. More... | |
Result | Y2RU_SetStandardCoefficient (Y2RU_StandardCoefficient coefficient) |
Used to configure the color conversion formula with ITU stantards coefficients. More... | |
Result | Y2RU_GetStandardCoefficient (Y2RU_ColorCoefficients *coefficients, Y2RU_StandardCoefficient standardCoeff) |
Gets the color coefficient parameters of a standard coefficient. More... | |
Result | Y2RU_SetAlpha (u16 alpha) |
Used to configure the alpha value of the output. More... | |
Result | Y2RU_GetAlpha (u16 *alpha) |
Gets the configured output alpha value. More... | |
Result | Y2RU_SetTransferEndInterrupt (bool should_interrupt) |
Used to enable the end of conversion interrupt. More... | |
Result | Y2RU_GetTransferEndInterrupt (bool *should_interrupt) |
Gets whether the transfer end interrupt is enabled. More... | |
Result | Y2RU_GetTransferEndEvent (Handle *end_event) |
Gets an handle to the end of conversion event. More... | |
Result | Y2RU_SetSendingY (const void *src_buf, u32 image_size, s16 transfer_unit, s16 transfer_gap) |
Configures the Y plane buffer. More... | |
Result | Y2RU_SetSendingU (const void *src_buf, u32 image_size, s16 transfer_unit, s16 transfer_gap) |
Configures the U plane buffer. More... | |
Result | Y2RU_SetSendingV (const void *src_buf, u32 image_size, s16 transfer_unit, s16 transfer_gap) |
Configures the V plane buffer. More... | |
Result | Y2RU_SetSendingYUYV (const void *src_buf, u32 image_size, s16 transfer_unit, s16 transfer_gap) |
Configures the YUYV source buffer. More... | |
Result | Y2RU_SetReceiving (void *dst_buf, u32 image_size, s16 transfer_unit, s16 transfer_gap) |
Configures the destination buffer. More... | |
Result | Y2RU_IsDoneSendingY (bool *is_done) |
Checks if the DMA has finished sending the Y buffer. More... | |
Result | Y2RU_IsDoneSendingU (bool *is_done) |
Checks if the DMA has finished sending the U buffer. More... | |
Result | Y2RU_IsDoneSendingV (bool *is_done) |
Checks if the DMA has finished sending the V buffer. More... | |
Result | Y2RU_IsDoneSendingYUYV (bool *is_done) |
Checks if the DMA has finished sending the YUYV buffer. More... | |
Result | Y2RU_IsDoneReceiving (bool *is_done) |
Checks if the DMA has finished sending the converted result. More... | |
Result | Y2RU_SetDitheringWeightParams (const Y2RU_DitheringWeightParams *params) |
Configures the dithering weight parameters. More... | |
Result | Y2RU_GetDitheringWeightParams (Y2RU_DitheringWeightParams *params) |
Gets the configured dithering weight parameters. More... | |
Result | Y2RU_SetConversionParams (const Y2RU_ConversionParams *params) |
Sets all of the parameters of Y2RU_ConversionParams at once. More... | |
Result | Y2RU_StartConversion (void) |
Starts the conversion process. | |
Result | Y2RU_StopConversion (void) |
Cancels the conversion. | |
Result | Y2RU_IsBusyConversion (bool *is_busy) |
Checks if the conversion and DMA transfer are finished. More... | |
Result | Y2RU_PingProcess (u8 *ping) |
Checks whether Y2R is ready to be used. More... | |
Result | Y2RU_DriverInitialize (void) |
Initializes the Y2R driver. | |
Result | Y2RU_DriverFinalize (void) |
Terminates the Y2R driver. | |
Y2R service for hardware YUV->RGB conversions.
enum Y2RU_BlockAlignment |
enum Y2RU_InputFormat |
Input color formats.
For the 16-bit per component formats, bits 15-8 are padding and 7-0 contains the value.
enum Y2RU_OutputFormat |
Output color formats.
Those are the same as the framebuffer and GPU texture formats.
Enumerator | |
---|---|
OUTPUT_RGB_32 | 32-bit RGBA8888. The alpha component is the 8-bit value set by Y2RU_SetAlpha |
OUTPUT_RGB_24 | 24-bit RGB888. |
OUTPUT_RGB_16_555 | 16-bit RGBA5551. The alpha bit is the 7th bit of the alpha value set by Y2RU_SetAlpha |
OUTPUT_RGB_16_565 | 16-bit RGB565. |
enum Y2RU_Rotation |
Preset conversion coefficients based on ITU standards for the YUV->RGB formula.
For more details refer to Y2RU_ColorCoefficients
void y2rExit | ( | void | ) |
Closes the y2r service.
This will internally call Y2RU_DriverFinalize and close the handle of the service.
Result y2rInit | ( | void | ) |
Initializes the y2r service.
This will internally get the handle of the service, and on success call Y2RU_DriverInitialize.
Gets the configured output alpha value.
alpha | Pointer to output the alpha value to. |
Result Y2RU_GetBlockAlignment | ( | Y2RU_BlockAlignment * | alignment | ) |
Gets the configured alignment.
alignment | Pointer to output the alignment to. |
Result Y2RU_GetCoefficients | ( | Y2RU_ColorCoefficients * | coefficients | ) |
Gets the configured color coefficients.
num_lines | Pointer to output the coefficients to. |
Result Y2RU_GetDitheringWeightParams | ( | Y2RU_DitheringWeightParams * | params | ) |
Gets the configured dithering weight parameters.
params | Pointer to output the dithering weight parameters to. |
Result Y2RU_GetInputFormat | ( | Y2RU_InputFormat * | format | ) |
Gets the configured input format.
format | Pointer to output the input format to. |
Gets the configured number of input lines.
num_lines | Pointer to output the input lines to. |
Gets the configured input line width.
line_width | Pointer to output the line width to. |
Result Y2RU_GetOutputFormat | ( | Y2RU_OutputFormat * | format | ) |
Gets the configured output format.
format | Pointer to output the output format to. |
Result Y2RU_GetRotation | ( | Y2RU_Rotation * | rotation | ) |
Gets the configured rotation.
rotation | Pointer to output the rotation to. |
Result Y2RU_GetSpacialDithering | ( | bool * | enabled | ) |
Gets whether to use spacial dithering.
enable | Pointer to output the spacial dithering state to. |
Result Y2RU_GetStandardCoefficient | ( | Y2RU_ColorCoefficients * | coefficients, |
Y2RU_StandardCoefficient | standardCoeff | ||
) |
Gets the color coefficient parameters of a standard coefficient.
coefficients | Pointer to output the coefficients to. |
standardCoeff | Standard coefficient to check. |
Result Y2RU_GetTemporalDithering | ( | bool * | enabled | ) |
Gets whether to use temporal dithering.
enable | Pointer to output the temporal dithering state to. |
Gets an handle to the end of conversion event.
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. |
To enable this event you have to use
The event will be triggered when the corresponding interrupt is fired.
Result Y2RU_GetTransferEndInterrupt | ( | bool * | should_interrupt | ) |
Gets whether the transfer end interrupt is enabled.
should_interrupt | Pointer to output the interrupt state to. |
Result Y2RU_IsBusyConversion | ( | bool * | is_busy | ) |
Checks if the conversion and DMA transfer are finished.
is_busy | Pointer to output the busy state to. |
This can have the same problems as the event and interrupt. See Y2RU_SetTransferEndInterrupt.
Result Y2RU_IsDoneReceiving | ( | bool * | is_done | ) |
Checks if the DMA has finished sending the converted result.
is_done | Pointer to the boolean that will hold the result. |
True if the DMA has finished transferring data to your destination buffer, false otherwise.
Result Y2RU_IsDoneSendingU | ( | bool * | is_done | ) |
Checks if the DMA has finished sending the U buffer.
is_done | Pointer to the boolean that will hold the result. |
True if the DMA has finished transferring the U plane, false otherwise. To be used with Y2RU_SetSendingU.
Result Y2RU_IsDoneSendingV | ( | bool * | is_done | ) |
Checks if the DMA has finished sending the V buffer.
is_done | Pointer to the boolean that will hold the result. |
True if the DMA has finished transferring the V plane, false otherwise. To be used with Y2RU_SetSendingV.
Result Y2RU_IsDoneSendingY | ( | bool * | is_done | ) |
Checks if the DMA has finished sending the Y buffer.
is_done | Pointer to the boolean that will hold the result. |
True if the DMA has finished transferring the Y plane, false otherwise. To be used with Y2RU_SetSendingY.
Result Y2RU_IsDoneSendingYUYV | ( | bool * | is_done | ) |
Checks if the DMA has finished sending the YUYV buffer.
is_done | Pointer to the boolean that will hold the result. |
True if the DMA has finished transferring the YUYV buffer, false otherwise. To be used with Y2RU_SetSendingYUYV.
Checks whether Y2R is ready to be used.
ping | Pointer to output the ready status to. |
Used to configure the alpha value of the output.
alpha | 8-bit value to be used for the output when the format requires it. |
Result Y2RU_SetBlockAlignment | ( | Y2RU_BlockAlignment | alignment | ) |
Used to configure the alignment of the output buffer.
alignment | Alignment to use. |
Result Y2RU_SetCoefficients | ( | const Y2RU_ColorCoefficients * | coefficients | ) |
Used to configure the color conversion formula.
coefficients | Coefficients to use. |
See Y2RU_ColorCoefficients for more information about the coefficients.
Result Y2RU_SetConversionParams | ( | const Y2RU_ConversionParams * | params | ) |
Sets all of the parameters of Y2RU_ConversionParams at once.
params | Conversion parameters to set. |
Faster than calling the individual value through Y2R_Set* because only one system call is made.
Result Y2RU_SetDitheringWeightParams | ( | const Y2RU_DitheringWeightParams * | params | ) |
Configures the dithering weight parameters.
params | Dithering weight parameters to use. |
Result Y2RU_SetInputFormat | ( | Y2RU_InputFormat | format | ) |
Used to configure the input format.
format | Input format to use. |
Used to configure the height of the image.
num_lines | Number of lines to be converted. |
A multiple of 8 seems to be preferred. If using the BLOCK_8_BY_8 mode, it must be a multiple of 8.
Used to configure the width of the image.
line_width | Width of the image in pixels. Must be a multiple of 8, up to 1024. |
Result Y2RU_SetOutputFormat | ( | Y2RU_OutputFormat | format | ) |
Used to configure the output format.
format | Output format to use. |
Configures the destination buffer.
src_buf | A pointer to the beginning of your destination buffer in FCRAM |
image_size | The total size of the data buffer. |
transfer_unit | Specifies the size of 1 DMA transfer. Usually set to 1 line. This has to be a divisor of image_size. |
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. |
This specifies the destination buffer of the conversion. The actual transfer will only happen after calling Y2RU_StartConversion. The buffer does NOT need to be allocated in the linear heap.
Result Y2RU_SetRotation | ( | Y2RU_Rotation | rotation | ) |
Used to configure the rotation of the output.
rotation | Rotation to use. |
It seems to apply the rotation per batch of 8 lines, so the output will be (height/8) images of size 8 x width.
Result Y2RU_SetSendingU | ( | const void * | src_buf, |
u32 | image_size, | ||
s16 | transfer_unit, | ||
s16 | transfer_gap | ||
) |
Configures the U plane buffer.
src_buf | A pointer to the beginning of your Y data buffer. |
image_size | The total size of the data buffer. |
transfer_unit | Specifies the size of 1 DMA transfer. Usually set to 1 line. This has to be a divisor of image_size. |
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. |
This specifies the U data buffer for the planar input formats (INPUT_YUV42*_INDIV_*). The actual transfer will only happen after calling Y2RU_StartConversion.
Result Y2RU_SetSendingV | ( | const void * | src_buf, |
u32 | image_size, | ||
s16 | transfer_unit, | ||
s16 | transfer_gap | ||
) |
Configures the V plane buffer.
src_buf | A pointer to the beginning of your Y data buffer. |
image_size | The total size of the data buffer. |
transfer_unit | Specifies the size of 1 DMA transfer. Usually set to 1 line. This has to be a divisor of image_size. |
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. |
This specifies the V data buffer for the planar input formats (INPUT_YUV42*_INDIV_*). The actual transfer will only happen after calling Y2RU_StartConversion.
Result Y2RU_SetSendingY | ( | const void * | src_buf, |
u32 | image_size, | ||
s16 | transfer_unit, | ||
s16 | transfer_gap | ||
) |
Configures the Y plane buffer.
src_buf | A pointer to the beginning of your Y data buffer. |
image_size | The total size of the data buffer. |
transfer_unit | Specifies the size of 1 DMA transfer. Usually set to 1 line. This has to be a divisor of image_size. |
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. |
This specifies the Y data buffer for the planar input formats (INPUT_YUV42*_INDIV_*). The actual transfer will only happen after calling Y2RU_StartConversion.
Result Y2RU_SetSendingYUYV | ( | const void * | src_buf, |
u32 | image_size, | ||
s16 | transfer_unit, | ||
s16 | transfer_gap | ||
) |
Configures the YUYV source buffer.
src_buf | A pointer to the beginning of your Y data buffer. |
image_size | The total size of the data buffer. |
transfer_unit | Specifies the size of 1 DMA transfer. Usually set to 1 line. This has to be a divisor of image_size. |
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. |
This specifies the YUYV data buffer for the packed input format INPUT_YUV422_BATCH. The actual transfer will only happen after calling Y2RU_StartConversion.
Result Y2RU_SetSpacialDithering | ( | bool | enable | ) |
Sets whether to use spacial dithering.
enable | Whether to use spacial dithering. |
Result Y2RU_SetStandardCoefficient | ( | Y2RU_StandardCoefficient | coefficient | ) |
Used to configure the color conversion formula with ITU stantards coefficients.
coefficient | Standard coefficient to use. |
See Y2RU_ColorCoefficients for more information about the coefficients.
Result Y2RU_SetTemporalDithering | ( | bool | enable | ) |
Sets whether to use temporal dithering.
enable | Whether to use temporal dithering. |
Result Y2RU_SetTransferEndInterrupt | ( | bool | should_interrupt | ) |
Used to enable the end of conversion interrupt.
should_interrupt | Enables the interrupt if true, disable it if false. |
It is possible to fire an interrupt when the conversion is finished, and that the DMA is done copying the data. This interrupt will then be used to fire an event. See Y2RU_GetTransferEndEvent. By default the interrupt is enabled.