mirror of
https://github.com/brain-hackers/u-boot-brain
synced 2024-09-25 06:00:25 +09:00
video: Avoid using #ifdef in video blitting code
This code does not really need to use #ifdef. We can use if() instead and gain build coverage without impacting code size. Change the #ifdefs to use IS_ENABLED() instead. Signed-off-by: Simon Glass <sjg@chromium.org>
This commit is contained in:
parent
512563ba0b
commit
46421197d5
@ -16,39 +16,36 @@
|
|||||||
static int console_normal_set_row(struct udevice *dev, uint row, int clr)
|
static int console_normal_set_row(struct udevice *dev, uint row, int clr)
|
||||||
{
|
{
|
||||||
struct video_priv *vid_priv = dev_get_uclass_priv(dev->parent);
|
struct video_priv *vid_priv = dev_get_uclass_priv(dev->parent);
|
||||||
void * __maybe_unused line;
|
void *line;
|
||||||
int __maybe_unused pixels = VIDEO_FONT_HEIGHT * vid_priv->xsize;
|
int pixels = VIDEO_FONT_HEIGHT * vid_priv->xsize;
|
||||||
int __maybe_unused i;
|
int i;
|
||||||
|
|
||||||
line = vid_priv->fb + row * VIDEO_FONT_HEIGHT * vid_priv->line_length;
|
line = vid_priv->fb + row * VIDEO_FONT_HEIGHT * vid_priv->line_length;
|
||||||
switch (vid_priv->bpix) {
|
switch (vid_priv->bpix) {
|
||||||
#ifdef CONFIG_VIDEO_BPP8
|
case VIDEO_BPP8:
|
||||||
case VIDEO_BPP8: {
|
if (IS_ENABLED(CONFIG_VIDEO_BPP8)) {
|
||||||
uint8_t *dst = line;
|
uint8_t *dst = line;
|
||||||
|
|
||||||
for (i = 0; i < pixels; i++)
|
for (i = 0; i < pixels; i++)
|
||||||
*dst++ = clr;
|
*dst++ = clr;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
#endif
|
case VIDEO_BPP16:
|
||||||
#ifdef CONFIG_VIDEO_BPP16
|
if (IS_ENABLED(CONFIG_VIDEO_BPP16)) {
|
||||||
case VIDEO_BPP16: {
|
uint16_t *dst = line;
|
||||||
uint16_t *dst = line;
|
|
||||||
|
|
||||||
for (i = 0; i < pixels; i++)
|
for (i = 0; i < pixels; i++)
|
||||||
*dst++ = clr;
|
*dst++ = clr;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
#endif
|
case VIDEO_BPP32:
|
||||||
#ifdef CONFIG_VIDEO_BPP32
|
if (IS_ENABLED(CONFIG_VIDEO_BPP32)) {
|
||||||
case VIDEO_BPP32: {
|
uint32_t *dst = line;
|
||||||
uint32_t *dst = line;
|
|
||||||
|
|
||||||
for (i = 0; i < pixels; i++)
|
for (i = 0; i < pixels; i++)
|
||||||
*dst++ = clr;
|
*dst++ = clr;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
default:
|
default:
|
||||||
return -ENOSYS;
|
return -ENOSYS;
|
||||||
}
|
}
|
||||||
@ -76,7 +73,7 @@ static int console_normal_putc_xy(struct udevice *dev, uint x_frac, uint y,
|
|||||||
struct vidconsole_priv *vc_priv = dev_get_uclass_priv(dev);
|
struct vidconsole_priv *vc_priv = dev_get_uclass_priv(dev);
|
||||||
struct udevice *vid = dev->parent;
|
struct udevice *vid = dev->parent;
|
||||||
struct video_priv *vid_priv = dev_get_uclass_priv(vid);
|
struct video_priv *vid_priv = dev_get_uclass_priv(vid);
|
||||||
int __maybe_unused i, row;
|
int i, row;
|
||||||
void *line = vid_priv->fb + y * vid_priv->line_length +
|
void *line = vid_priv->fb + y * vid_priv->line_length +
|
||||||
VID_TO_PIXEL(x_frac) * VNBYTES(vid_priv->bpix);
|
VID_TO_PIXEL(x_frac) * VNBYTES(vid_priv->bpix);
|
||||||
|
|
||||||
@ -85,45 +82,45 @@ static int console_normal_putc_xy(struct udevice *dev, uint x_frac, uint y,
|
|||||||
|
|
||||||
for (row = 0; row < VIDEO_FONT_HEIGHT; row++) {
|
for (row = 0; row < VIDEO_FONT_HEIGHT; row++) {
|
||||||
unsigned int idx = (u8)ch * VIDEO_FONT_HEIGHT + row;
|
unsigned int idx = (u8)ch * VIDEO_FONT_HEIGHT + row;
|
||||||
uchar __maybe_unused bits = video_fontdata[idx];
|
uchar bits = video_fontdata[idx];
|
||||||
|
|
||||||
switch (vid_priv->bpix) {
|
switch (vid_priv->bpix) {
|
||||||
#ifdef CONFIG_VIDEO_BPP8
|
case VIDEO_BPP8:
|
||||||
case VIDEO_BPP8: {
|
if (IS_ENABLED(CONFIG_VIDEO_BPP8)) {
|
||||||
uint8_t *dst = line;
|
uint8_t *dst = line;
|
||||||
|
|
||||||
for (i = 0; i < VIDEO_FONT_WIDTH; i++) {
|
for (i = 0; i < VIDEO_FONT_WIDTH; i++) {
|
||||||
*dst++ = (bits & 0x80) ? vid_priv->colour_fg
|
*dst++ = (bits & 0x80) ?
|
||||||
: vid_priv->colour_bg;
|
vid_priv->colour_fg :
|
||||||
bits <<= 1;
|
vid_priv->colour_bg;
|
||||||
|
bits <<= 1;
|
||||||
|
}
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
break;
|
case VIDEO_BPP16:
|
||||||
}
|
if (IS_ENABLED(CONFIG_VIDEO_BPP16)) {
|
||||||
#endif
|
uint16_t *dst = line;
|
||||||
#ifdef CONFIG_VIDEO_BPP16
|
|
||||||
case VIDEO_BPP16: {
|
|
||||||
uint16_t *dst = line;
|
|
||||||
|
|
||||||
for (i = 0; i < VIDEO_FONT_WIDTH; i++) {
|
for (i = 0; i < VIDEO_FONT_WIDTH; i++) {
|
||||||
*dst++ = (bits & 0x80) ? vid_priv->colour_fg
|
*dst++ = (bits & 0x80) ?
|
||||||
: vid_priv->colour_bg;
|
vid_priv->colour_fg :
|
||||||
bits <<= 1;
|
vid_priv->colour_bg;
|
||||||
|
bits <<= 1;
|
||||||
|
}
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
break;
|
case VIDEO_BPP32:
|
||||||
}
|
if (IS_ENABLED(CONFIG_VIDEO_BPP32)) {
|
||||||
#endif
|
uint32_t *dst = line;
|
||||||
#ifdef CONFIG_VIDEO_BPP32
|
|
||||||
case VIDEO_BPP32: {
|
|
||||||
uint32_t *dst = line;
|
|
||||||
|
|
||||||
for (i = 0; i < VIDEO_FONT_WIDTH; i++) {
|
for (i = 0; i < VIDEO_FONT_WIDTH; i++) {
|
||||||
*dst++ = (bits & 0x80) ? vid_priv->colour_fg
|
*dst++ = (bits & 0x80) ?
|
||||||
: vid_priv->colour_bg;
|
vid_priv->colour_fg :
|
||||||
bits <<= 1;
|
vid_priv->colour_bg;
|
||||||
|
bits <<= 1;
|
||||||
|
}
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
break;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
default:
|
default:
|
||||||
return -ENOSYS;
|
return -ENOSYS;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user