@ -21,6 +21,7 @@
# include "hw/virtio/virtio.h"
# include "hw/virtio/virtio-gpu.h"
# include "hw/virtio/virtio-bus.h"
# include "hw/display/edid.h"
# include "migration/blocker.h"
# include "qemu/log.h"
# include "qapi/error.h"
@ -207,6 +208,9 @@ static uint64_t virtio_gpu_get_features(VirtIODevice *vdev, uint64_t features,
if ( virtio_gpu_virgl_enabled ( g - > conf ) ) {
features | = ( 1 < < VIRTIO_GPU_F_VIRGL ) ;
}
if ( virtio_gpu_edid_enabled ( g - > conf ) ) {
features | = ( 1 < < VIRTIO_GPU_F_EDID ) ;
}
return features ;
}
@ -301,6 +305,40 @@ void virtio_gpu_get_display_info(VirtIOGPU *g,
sizeof ( display_info ) ) ;
}
static void
virtio_gpu_generate_edid ( VirtIOGPU * g , int scanout ,
struct virtio_gpu_resp_edid * edid )
{
qemu_edid_info info = {
. prefx = g - > req_state [ scanout ] . width ,
. prefy = g - > req_state [ scanout ] . height ,
} ;
edid - > size = cpu_to_le32 ( sizeof ( edid - > edid ) ) ;
qemu_edid_generate ( edid - > edid , sizeof ( edid - > edid ) , & info ) ;
}
void virtio_gpu_get_edid ( VirtIOGPU * g ,
struct virtio_gpu_ctrl_command * cmd )
{
struct virtio_gpu_resp_edid edid ;
struct virtio_gpu_cmd_get_edid get_edid ;
VIRTIO_GPU_FILL_CMD ( get_edid ) ;
virtio_gpu_bswap_32 ( & get_edid , sizeof ( get_edid ) ) ;
if ( get_edid . scanout > = g - > conf . max_outputs ) {
cmd - > error = VIRTIO_GPU_RESP_ERR_INVALID_PARAMETER ;
return ;
}
trace_virtio_gpu_cmd_get_edid ( get_edid . scanout ) ;
memset ( & edid , 0 , sizeof ( edid ) ) ;
edid . hdr . type = VIRTIO_GPU_RESP_OK_EDID ;
virtio_gpu_generate_edid ( g , get_edid . scanout , & edid ) ;
virtio_gpu_ctrl_response ( g , cmd , & edid . hdr , sizeof ( edid ) ) ;
}
static pixman_format_code_t get_pixman_format ( uint32_t virtio_gpu_format )
{
switch ( virtio_gpu_format ) {
@ -839,6 +877,9 @@ static void virtio_gpu_simple_process_cmd(VirtIOGPU *g,
case VIRTIO_GPU_CMD_GET_DISPLAY_INFO :
virtio_gpu_get_display_info ( g , cmd ) ;
break ;
case VIRTIO_GPU_CMD_GET_EDID :
virtio_gpu_get_edid ( g , cmd ) ;
break ;
case VIRTIO_GPU_CMD_RESOURCE_CREATE_2D :
virtio_gpu_resource_create_2d ( g , cmd ) ;
break ;
@ -1369,6 +1410,8 @@ static Property virtio_gpu_properties[] = {
DEFINE_PROP_BIT ( " stats " , VirtIOGPU , conf . flags ,
VIRTIO_GPU_FLAG_STATS_ENABLED , false ) ,
# endif
DEFINE_PROP_BIT ( " edid " , VirtIOGPU , conf . flags ,
VIRTIO_GPU_FLAG_EDID_ENABLED , false ) ,
DEFINE_PROP_UINT32 ( " xres " , VirtIOGPU , conf . xres , 1024 ) ,
DEFINE_PROP_UINT32 ( " yres " , VirtIOGPU , conf . yres , 768 ) ,
DEFINE_PROP_END_OF_LIST ( ) ,