sun60iw2: make logo framebuffer path debuggable

This commit is contained in:
Qubot 2026-06-04 12:05:52 +08:00
parent ca6040d8b7
commit 361f84346d

View File

@ -862,7 +862,7 @@ static int sunxi_drm_drv_probe(struct udevice *dev)
sunxi_drm_for_each_display(tmp_s, drm) {
cmd2.width = tmp_s->conn_state.mode.hdisplay;
cmd2.height = tmp_s->conn_state.mode.vdisplay;
cmd2.pixel_format = DRM_FORMAT_ARGB8888;
cmd2.pixel_format = DRM_FORMAT_XRGB8888;
cmd2.pitches[0] = cmd2.width * (ALIGN(32, 8) >> 3);
cmd2.offsets[0] = 0;
tmp_s->fb_id = drm_framebuffer_alloc(drm, &cmd2);
@ -1024,6 +1024,7 @@ static int display_set_plane(struct display_state *state)
struct connector_state *conn_state = &state->conn_state;
struct drm_mode_set_plane plane_req;
struct drm_display_mode *mode = &conn_state->mode;
int ret;
if (!state->is_init)
return -EINVAL;
@ -1039,6 +1040,12 @@ static int display_set_plane(struct display_state *state)
}
plane_req.plane_id = drm_get_primary_plane_id(state->drm, plane_req.crtc_id);
if (plane_req.plane_id < 0) {
DRM_ERROR("Failed to get primary plane for crtc %d\n",
plane_req.crtc_id);
return -ENODEV;
}
plane_req.crtc_x = 0;
plane_req.crtc_y = 0;
plane_req.crtc_w = mode->hdisplay;
@ -1048,7 +1055,13 @@ static int display_set_plane(struct display_state *state)
plane_req.src_w = mode->hdisplay << 16;
plane_req.src_h = mode->vdisplay << 16;
return drm_mode_setplane(state->drm, &plane_req);
ret = drm_mode_setplane(state->drm, &plane_req);
if (ret)
DRM_ERROR("Failed to set plane %d fb %d on crtc %d: %d\n",
plane_req.plane_id, plane_req.fb_id,
plane_req.crtc_id, ret);
return ret;
}
@ -1057,6 +1070,7 @@ static int display_enable(struct display_state *state)
struct crtc_state *crtc_state = &state->crtc_state;
const struct sunxi_drm_crtc *crtc = crtc_state->crtc;
const struct sunxi_drm_crtc_funcs *crtc_funcs = crtc->funcs;
int ret;
/*struct drm_framebuffer *fb = NULL;*/
/*struct video_priv *uc_priv = dev_get_uclass_priv(state->drm->dev);*/
@ -1074,7 +1088,9 @@ static int display_enable(struct display_state *state)
if (crtc_funcs->enable)
crtc_funcs->enable(state);
display_set_plane(state);
ret = display_set_plane(state);
if (ret)
return ret;
sunxi_drm_connector_enable(state);
@ -1423,14 +1439,16 @@ static int display_logo(struct display_state *state)
}
fb = drm_framebuffer_lookup(state->drm, state->fb_id);
if (fb) {
memset((void *)fb->dma_addr, 0, fb->buf_size);
flush_dcache_range((ulong)fb->dma_addr,
ALIGN((ulong)(fb->dma_addr + fb->buf_size),
CONFIG_SYS_CACHELINE_SIZE));
if (!fb) {
DRM_ERROR("Logo framebuffer %d not found\n", state->fb_id);
return -ENOMEM;
}
memset((void *)fb->dma_addr, 0, fb->buf_size);
flush_dcache_range((ulong)fb->dma_addr,
ALIGN((ulong)(fb->dma_addr + fb->buf_size),
CONFIG_SYS_CACHELINE_SIZE));
// FIXME: dual display, modify it if some new demands need later
if (plat->base != fb->dma_addr) {
plat->base = fb->dma_addr;
@ -1448,7 +1466,20 @@ static int display_logo(struct display_state *state)
if (fb->height > bmp->header.height)
upper_offset = ((fb->height - bmp->header.height) >> 1);
DRM_INFO("logo: fb %dx%d fmt %c%c%c%c addr 0x%lx size %u, bmp %ux%u bpp %u offset %d,%d\n",
fb->width, fb->height,
fb->format->format & 0xff,
(fb->format->format >> 8) & 0xff,
(fb->format->format >> 16) & 0xff,
(fb->format->format >> 24) & 0xff,
(ulong)fb->dma_addr, fb->buf_size,
bmp->header.width, bmp->header.height,
bmp->header.bit_count, left_offset, upper_offset);
bmp_display((ulong)state->logo->file_addr, left_offset, upper_offset);
flush_dcache_range((ulong)fb->dma_addr,
ALIGN((ulong)(fb->dma_addr + fb->buf_size),
CONFIG_SYS_CACHELINE_SIZE));
ret = display_enable(state);
if (ret) {