[bsp/qemu-virt64-aarch64] Fixup VirtIO queue align size (#6096)
This commit is contained in:
parent
f41cb5636f
commit
5774dcac8f
|
@ -23,9 +23,12 @@ static rt_uint32_t cur_range[2];
|
||||||
static rt_uint32_t cur_points[2];
|
static rt_uint32_t cur_points[2];
|
||||||
static rt_uint32_t cur_last_points[2];
|
static rt_uint32_t cur_last_points[2];
|
||||||
static rt_bool_t cur_event_sync;
|
static rt_bool_t cur_event_sync;
|
||||||
|
static rt_uint32_t color[2] = { 0xff0000, 0x0000ff };
|
||||||
|
|
||||||
void tablet_event_handler(struct virtio_input_event event)
|
void tablet_event_handler(struct virtio_input_event event)
|
||||||
{
|
{
|
||||||
|
static rt_bool_t cur_btn_down = RT_FALSE;
|
||||||
|
|
||||||
if (event.type == EV_ABS)
|
if (event.type == EV_ABS)
|
||||||
{
|
{
|
||||||
if (event.code == 0)
|
if (event.code == 0)
|
||||||
|
@ -37,6 +40,24 @@ void tablet_event_handler(struct virtio_input_event event)
|
||||||
cur_points[1] = (cur_max[1] * (event.value - cur_min[1]) + cur_range[1] / 2) / cur_range[1];
|
cur_points[1] = (cur_max[1] * (event.value - cur_min[1]) + cur_range[1] / 2) / cur_range[1];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else if (event.type == EV_KEY)
|
||||||
|
{
|
||||||
|
if (event.code == BTN_LEFT)
|
||||||
|
{
|
||||||
|
if (cur_btn_down && event.value == 0)
|
||||||
|
{
|
||||||
|
color[0] ^= color[1];
|
||||||
|
color[1] ^= color[0];
|
||||||
|
color[0] ^= color[1];
|
||||||
|
cur_btn_down = RT_FALSE;
|
||||||
|
cur_event_sync = RT_TRUE;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
cur_btn_down = RT_TRUE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
else if (event.type == EV_SYN)
|
else if (event.type == EV_SYN)
|
||||||
{
|
{
|
||||||
cur_event_sync = RT_TRUE;
|
cur_event_sync = RT_TRUE;
|
||||||
|
@ -52,8 +73,6 @@ void graphic_thread(void *param)
|
||||||
rt_device_t tablet_dev = RT_NULL;
|
rt_device_t tablet_dev = RT_NULL;
|
||||||
struct virtio_input_config tablet_config;
|
struct virtio_input_config tablet_config;
|
||||||
|
|
||||||
rt_uint32_t red = 0xff0000;
|
|
||||||
rt_uint32_t blue = 0x0000ff;
|
|
||||||
rt_uint32_t white = 0xffffff;
|
rt_uint32_t white = 0xffffff;
|
||||||
rt_device_t gpu_dev = RT_NULL;
|
rt_device_t gpu_dev = RT_NULL;
|
||||||
struct rt_device_rect_info rect_info;
|
struct rt_device_rect_info rect_info;
|
||||||
|
@ -87,15 +106,13 @@ void graphic_thread(void *param)
|
||||||
cur_last_points[0] = graphic_info.width / 2;
|
cur_last_points[0] = graphic_info.width / 2;
|
||||||
cur_last_points[1] = graphic_info.height / 2;
|
cur_last_points[1] = graphic_info.height / 2;
|
||||||
|
|
||||||
virtio_gpu_graphic_ops->draw_hline((char *)&red, 0, graphic_info.width, cur_last_points[1]);
|
virtio_gpu_graphic_ops->draw_hline((char *)&color[0], 0, graphic_info.width, cur_last_points[1]);
|
||||||
virtio_gpu_graphic_ops->draw_vline((char *)&blue, cur_last_points[0], 0, graphic_info.height);
|
virtio_gpu_graphic_ops->draw_vline((char *)&color[1], cur_last_points[0], 0, graphic_info.height);
|
||||||
|
|
||||||
rt_device_control(device, RTGRAPHIC_CTRL_RECT_UPDATE, &rect_info);
|
rt_device_control(device, RTGRAPHIC_CTRL_RECT_UPDATE, &rect_info);
|
||||||
|
|
||||||
gpu_dev = device;
|
gpu_dev = device;
|
||||||
}
|
}
|
||||||
|
|
||||||
rt_device_close(device);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Keyboard, Mouse, Tablet */
|
/* Keyboard, Mouse, Tablet */
|
||||||
|
@ -153,8 +170,8 @@ void graphic_thread(void *param)
|
||||||
cur_last_points[0] = cur_points[0];
|
cur_last_points[0] = cur_points[0];
|
||||||
cur_last_points[1] = cur_points[1];
|
cur_last_points[1] = cur_points[1];
|
||||||
|
|
||||||
virtio_gpu_graphic_ops->draw_hline((char *)&red, 0, graphic_info.width, cur_last_points[1]);
|
virtio_gpu_graphic_ops->draw_hline((char *)&color[0], 0, graphic_info.width, cur_last_points[1]);
|
||||||
virtio_gpu_graphic_ops->draw_vline((char *)&blue, cur_last_points[0], 0, graphic_info.height);
|
virtio_gpu_graphic_ops->draw_vline((char *)&color[1], cur_last_points[0], 0, graphic_info.height);
|
||||||
|
|
||||||
rt_device_control(gpu_dev, RTGRAPHIC_CTRL_RECT_UPDATE, &rect_info);
|
rt_device_control(gpu_dev, RTGRAPHIC_CTRL_RECT_UPDATE, &rect_info);
|
||||||
|
|
||||||
|
|
|
@ -72,7 +72,7 @@ rt_err_t virtio_queue_init(struct virtio_device *dev, rt_uint32_t queue_index, r
|
||||||
|
|
||||||
queue = &dev->queues[queue_index];
|
queue = &dev->queues[queue_index];
|
||||||
pages_total_size = VIRTIO_PAGE_ALIGN(
|
pages_total_size = VIRTIO_PAGE_ALIGN(
|
||||||
VIRTQ_DESC_TOTAL_SIZE(ring_size) + VIRTQ_AVAIL_TOTAL_SIZE(ring_size) + VIRTQ_USED_TOTAL_SIZE(ring_size));
|
VIRTQ_DESC_TOTAL_SIZE(ring_size) + VIRTQ_AVAIL_TOTAL_SIZE(ring_size)) + VIRTQ_USED_TOTAL_SIZE(ring_size);
|
||||||
|
|
||||||
pages = rt_malloc_align(pages_total_size, VIRTIO_PAGE_SIZE);
|
pages = rt_malloc_align(pages_total_size, VIRTIO_PAGE_SIZE);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue