kopia lustrzana https://github.com/Wren6991/PicoDVI
Make RGB component layout configurable, including BGR/RGB swap
rodzic
5034a9abff
commit
855546c03e
|
@ -119,18 +119,10 @@ static inline void __dvi_func_x(_dvi_prepare_scanline_8bpp)(struct dvi_inst *ins
|
|||
queue_remove_blocking_u32(&inst->q_tmds_free, &tmdsbuf);
|
||||
uint pixwidth = inst->timing->h_active_pixels;
|
||||
uint words_per_channel = pixwidth / DVI_SYMBOLS_PER_WORD;
|
||||
// TODO maybe want to make this configurable one day
|
||||
// anyhoo we are abutting the buffers in TMDS channel order
|
||||
const uint red_msb = 7;
|
||||
const uint red_lsb = 5;
|
||||
const uint green_msb = 4;
|
||||
const uint green_lsb = 2;
|
||||
const uint blue_msb = 1;
|
||||
const uint blue_lsb = 0;
|
||||
// Scanline buffers are half-resolution; the functions take the number of *input* pixels as parameter.
|
||||
tmds_encode_data_channel_8bpp(scanbuf, tmdsbuf + 0 * words_per_channel, pixwidth / 2, blue_msb, blue_lsb);
|
||||
tmds_encode_data_channel_8bpp(scanbuf, tmdsbuf + 1 * words_per_channel, pixwidth / 2, green_msb, green_lsb);
|
||||
tmds_encode_data_channel_8bpp(scanbuf, tmdsbuf + 2 * words_per_channel, pixwidth / 2, red_msb, red_lsb);
|
||||
tmds_encode_data_channel_8bpp(scanbuf, tmdsbuf + 0 * words_per_channel, pixwidth / 2, DVI_8BPP_BLUE_MSB, DVI_8BPP_BLUE_LSB );
|
||||
tmds_encode_data_channel_8bpp(scanbuf, tmdsbuf + 1 * words_per_channel, pixwidth / 2, DVI_8BPP_GREEN_MSB, DVI_8BPP_GREEN_LSB);
|
||||
tmds_encode_data_channel_8bpp(scanbuf, tmdsbuf + 2 * words_per_channel, pixwidth / 2, DVI_8BPP_RED_MSB, DVI_8BPP_RED_LSB );
|
||||
queue_add_blocking_u32(&inst->q_tmds_valid, &tmdsbuf);
|
||||
}
|
||||
|
||||
|
@ -139,15 +131,9 @@ static inline void __dvi_func_x(_dvi_prepare_scanline_16bpp)(struct dvi_inst *in
|
|||
queue_remove_blocking_u32(&inst->q_tmds_free, &tmdsbuf);
|
||||
uint pixwidth = inst->timing->h_active_pixels;
|
||||
uint words_per_channel = pixwidth / DVI_SYMBOLS_PER_WORD;
|
||||
const uint red_msb = 15;
|
||||
const uint red_lsb = 11;
|
||||
const uint green_msb = 10;
|
||||
const uint green_lsb = 5;
|
||||
const uint blue_msb = 4;
|
||||
const uint blue_lsb = 0;
|
||||
tmds_encode_data_channel_16bpp(scanbuf, tmdsbuf + 0 * words_per_channel, pixwidth / 2, blue_msb, blue_lsb);
|
||||
tmds_encode_data_channel_16bpp(scanbuf, tmdsbuf + 1 * words_per_channel, pixwidth / 2, green_msb, green_lsb);
|
||||
tmds_encode_data_channel_16bpp(scanbuf, tmdsbuf + 2 * words_per_channel, pixwidth / 2, red_msb, red_lsb);
|
||||
tmds_encode_data_channel_16bpp(scanbuf, tmdsbuf + 0 * words_per_channel, pixwidth / 2, DVI_16BPP_BLUE_MSB, DVI_16BPP_BLUE_LSB );
|
||||
tmds_encode_data_channel_16bpp(scanbuf, tmdsbuf + 1 * words_per_channel, pixwidth / 2, DVI_16BPP_GREEN_MSB, DVI_16BPP_GREEN_LSB);
|
||||
tmds_encode_data_channel_16bpp(scanbuf, tmdsbuf + 2 * words_per_channel, pixwidth / 2, DVI_16BPP_RED_MSB, DVI_16BPP_RED_LSB );
|
||||
queue_add_blocking_u32(&inst->q_tmds_valid, &tmdsbuf);
|
||||
}
|
||||
|
||||
|
|
|
@ -55,6 +55,64 @@
|
|||
#error "Unsupported value for DVI_SYMBOLS_PER_WORD"
|
||||
#endif
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// Pixel component layout
|
||||
|
||||
// By default we go R, G, B from MSB -> LSB. Override to e.g. swap RGB <-> BGR
|
||||
|
||||
// Default 8bpp layout: RGB332, {r[1:0], g[2:0], b[1:0]}
|
||||
|
||||
#ifndef DVI_8BPP_RED_MSB
|
||||
#define DVI_8BPP_RED_MSB 7
|
||||
#endif
|
||||
|
||||
#ifndef DVI_8BPP_RED_LSB
|
||||
#define DVI_8BPP_RED_LSB 5
|
||||
#endif
|
||||
|
||||
#ifndef DVI_8BPP_GREEN_MSB
|
||||
#define DVI_8BPP_GREEN_MSB 4
|
||||
#endif
|
||||
|
||||
#ifndef DVI_8BPP_GREEN_LSB
|
||||
#define DVI_8BPP_GREEN_LSB 2
|
||||
#endif
|
||||
|
||||
#ifndef DVI_8BPP_BLUE_MSB
|
||||
#define DVI_8BPP_BLUE_MSB 1
|
||||
#endif
|
||||
|
||||
#ifndef DVI_8BPP_BLUE_LSB
|
||||
#define DVI_8BPP_BLUE_LSB 0
|
||||
#endif
|
||||
|
||||
// Default 16bpp layout: RGB565, {r[4:0], g[5:0], b[4:0]}
|
||||
|
||||
#ifndef DVI_16BPP_RED_MSB
|
||||
#define DVI_16BPP_RED_MSB 15
|
||||
#endif
|
||||
|
||||
#ifndef DVI_16BPP_RED_LSB
|
||||
#define DVI_16BPP_RED_LSB 11
|
||||
#endif
|
||||
|
||||
#ifndef DVI_16BPP_GREEN_MSB
|
||||
#define DVI_16BPP_GREEN_MSB 10
|
||||
#endif
|
||||
|
||||
#ifndef DVI_16BPP_GREEN_LSB
|
||||
#define DVI_16BPP_GREEN_LSB 5
|
||||
#endif
|
||||
|
||||
#ifndef DVI_16BPP_BLUE_MSB
|
||||
#define DVI_16BPP_BLUE_MSB 4
|
||||
#endif
|
||||
|
||||
#ifndef DVI_16BPP_BLUE_LSB
|
||||
#define DVI_16BPP_BLUE_LSB 0
|
||||
#endif
|
||||
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// TMDS encode controls
|
||||
|
||||
|
@ -82,5 +140,4 @@
|
|||
#define TMDS_FULLRES_NO_DC_BALANCE 0
|
||||
#endif
|
||||
|
||||
|
||||
#endif
|
||||
|
|
Ładowanie…
Reference in New Issue