summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorfangjianzhou <[email protected]>2023-10-18 08:29:24 +0800
committerGitHub <[email protected]>2023-10-18 08:29:24 +0800
commitdd33b31c280124526dc7aaf7c11e4b1eadf9d6b3 (patch)
tree7ccc498e4ff388101fc219312bdc90f9cb712d1d
parent7f6f086601a5e3f964dc6d3bf958d1eb250b7d0e (diff)
修改virtio.c存在的问题 (#8146)
-rw-r--r--components/drivers/virtio/virtio.c23
1 files changed, 21 insertions, 2 deletions
diff --git a/components/drivers/virtio/virtio.c b/components/drivers/virtio/virtio.c
index f8894b70c2..0ad924e9d7 100644
--- a/components/drivers/virtio/virtio.c
+++ b/components/drivers/virtio/virtio.c
@@ -370,6 +370,16 @@ static rt_err_t fb_control(rt_device_t dev, int cmd, void *args)
info->bits_per_pixel = _graphic_info.bits_per_pixel;
info->xres = _graphic_info.width;
info->yres = _graphic_info.height;
+ info->yres_virtual = _graphic_info.height;
+ info->xres_virtual = _graphic_info.width;
+ info->transp.offset = 24;
+ info->transp.length = 8;
+ info->red.offset = 0;
+ info->red.length = 8;
+ info->green.offset = 8;
+ info->green.length = 8;
+ info->blue.offset = 16;
+ info->blue.length = 8;
break;
}
case RT_FIOMMAP2:
@@ -409,7 +419,11 @@ const static struct rt_device_ops fb_ops =
static int fb_init()
{
_gpu_dev = rt_device_find("virtio-gpu0");
- RT_ASSERT(_gpu_dev);
+
+ if(_gpu_dev == RT_NULL)
+ {
+ return -RT_ERROR;
+ }
if(_gpu_dev != RT_NULL && rt_device_open(_gpu_dev, 0) == RT_EOK)
{
@@ -426,7 +440,12 @@ static int fb_init()
rt_device_control(_gpu_dev, RTGRAPHIC_CTRL_RECT_UPDATE, &_rect_info);
}
- RT_ASSERT(!rt_device_find("fb0"));
+ if(rt_device_find("fb0") != RT_NULL)
+ {
+ rt_kprintf("a device named fb0 already exists\n");
+ return -RT_ERROR;
+ }
+
_fb.type = RT_Device_Class_Miscellaneous;
#ifdef RT_USING_DEVICE_OPS