| 417 | #endif |
| 418 | |
| 419 | static int fb_init() |
| 420 | { |
| 421 | _gpu_dev = rt_device_find("virtio-gpu0"); |
| 422 | |
| 423 | if(_gpu_dev == RT_NULL) |
| 424 | { |
| 425 | return -RT_ERROR; |
| 426 | } |
| 427 | |
| 428 | if(_gpu_dev != RT_NULL && rt_device_open(_gpu_dev, 0) == RT_EOK) |
| 429 | { |
| 430 | rt_memset(&_graphic_info, 0, sizeof(_graphic_info)); |
| 431 | rt_memset(&_rect_info, 0, sizeof(_rect_info)); |
| 432 | rt_device_control(_gpu_dev, VIRTIO_DEVICE_CTRL_GPU_SET_PRIMARY, RT_NULL); |
| 433 | rt_device_control(_gpu_dev, VIRTIO_DEVICE_CTRL_GPU_CREATE_2D, (void *)RTGRAPHIC_PIXEL_FORMAT_RGB888); |
| 434 | rt_device_control(_gpu_dev, RTGRAPHIC_CTRL_GET_INFO, &_graphic_info); |
| 435 | _rect_info.x = 0; |
| 436 | _rect_info.y = 0; |
| 437 | _rect_info.width = _graphic_info.width; |
| 438 | _rect_info.height = _graphic_info.height; |
| 439 | memset(_graphic_info.framebuffer, 0xff, _graphic_info.smem_len); |
| 440 | rt_device_control(_gpu_dev, RTGRAPHIC_CTRL_RECT_UPDATE, &_rect_info); |
| 441 | } |
| 442 | |
| 443 | if(rt_device_find("fb0") != RT_NULL) |
| 444 | { |
| 445 | rt_kprintf("a device named fb0 already exists\n"); |
| 446 | return -RT_ERROR; |
| 447 | } |
| 448 | |
| 449 | _fb.type = RT_Device_Class_Miscellaneous; |
| 450 | |
| 451 | #ifdef RT_USING_DEVICE_OPS |
| 452 | _fb.ops = &fb_ops; |
| 453 | #else |
| 454 | _fb.init = RT_NULL; |
| 455 | _fb.open = fb_open; |
| 456 | _fb.close = fb_close; |
| 457 | _fb.read = RT_NULL; |
| 458 | _fb.write = RT_NULL; |
| 459 | _fb.control = fb_control; |
| 460 | _fb.user_data = RT_NULL; |
| 461 | #endif |
| 462 | |
| 463 | rt_device_register(&_fb, "fb0", RT_DEVICE_FLAG_RDWR); |
| 464 | return RT_EOK; |
| 465 | } |
| 466 | INIT_COMPONENT_EXPORT(fb_init); |
| 467 | #endif |
| 468 | #endif |
nothing calls this directly
no test coverage detected