Thread: Virtual box
View Single Post
Old 06-14-2017, 04:38 AM   #3
Irene
Junior Member
 
Join Date: Jun 2017
Posts: 4
Default

Hi,

I am going through those files. Like I said very new to this domain, it is difficult to understand without documentation.

Code :

#include <stdio.h>
#include <stdint.h>
#include <string.h>
#include "evdi_lib.h"
#include <stdlib.h>
#include <unistd.h>

int main(){
int new_node = 0;
int dev_status = 0;
evdi_handle new_handle;
evdi_buffer new_buffer;
const unsigned char* edid;
bool update;
char opt[3];

int *new_rect_num; // buffer description
new_buffer.id=0;
int new_buf_id=new_buffer.id;
new_buffer.width=1920; // Horizontal size
new_buffer.height=1096; // Vertical size
new_buffer.stride=1920;
new_buffer.rect_count=100; // frame count
new_rect_num=&new_buffer.rect_count;

const unsigned char edid_dummy[128]={
0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x58, 0x58, 0x00, 0x00, 0x80, 0x07, 0x48, 0x04,
0x01, 0x00, 0x01, 0x03, 0x80, 0x00, 0x00, 0x78, 0xEE, 0xEE, 0x91, 0xA3, 0x54, 0x4C, 0x99, 0x26,
0x0F, 0x50, 0x54, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0xBE, 0x31, 0x80, 0x06, 0x70, 0x48, 0x06, 0x40, 0x02, 0x02,
0x02, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFD, 0x00, 0x00, 0xC8, 0x00,
0xC8, 0x64, 0x00, 0x0A, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x00, 0x00, 0x00, 0xFC, 0x00, 0x56,
0x42, 0x4F, 0x58, 0x20, 0x6D, 0x6F, 0x6E, 0x69, 0x74, 0x6F, 0x72, 0x0A, 0x00, 0x00, 0x00, 0x10,
0x00, 0x0A, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x00, 0x17};

edid=edid_dummy;

evdi_selectable new_selectable;
evdi_event_context node_context;
evdi_event_context* new_context;
new_context=&node_context;

new_node = evdi_add_device(); // Adding new EVDI node
if (new_node>0)
{
printf("\n New EVDI node added\n");

dev_status = evdi_check_device(new_node); // Checking if the above node is available EVDI node for use
printf(" Status of the node : ");

if (dev_status == AVAILABLE)
{
printf(" AVAILABLE\n");
new_handle = evdi_open(new_node);
printf(" Status of the EVDI handle : ");
if (new_handle == EVDI_INVALID_HANDLE)
{
printf(" EVDI_INVALID_HANDLE\n");
}
else
{
printf(" EVDI_VALID_HANDLE\n");

evdi_connect(new_handle,edid,130,1096); // Opening connections
printf(" Opening connections\n");

evdi_register_buffer(new_handle, new_buffer); // Registering Buffers
printf(" Registering Buffers\n");

new_selectable=evdi_get_event_ready(new_handle);
printf(" Event Handler = %d\n",new_selectable);
evdi_handle_events(new_handle, new_context); // Event Handler


update=evdi_request_update(new_handle, new_buf_id); // Requesting screen update
printf(" Screen Update Status : %s\n", update?"TRUE":"FALSE");

evdi_grab_pixels(new_handle, new_buffer.rects, new_rect_num); // Grabbing pixels


evdi_unregister_buffer(new_handle, new_buf_id); // Unregistering Buffers
printf(" Unregistering Buffers\n");

evdi_disconnect(new_handle); // Disconnecting
printf(" Disconnecting\n");

evdi_close(new_handle); // Closing devices
printf(" Closing devices\n \n ");
}
}

else if (dev_status == UNRECOGNIZED)
printf(" UNRECOGNIZED\n \n");
else
printf(" NOT_PRESENT\n \n");
}

else
printf(" Error occurred while adding a new EVDI node \n \n");

return 0;
}



Code Output :

New EVDI node added
Process id : 25308
Match found : 7f93f547f000-7f93f577f000 rw-s 100004000 00:06 463 /dev/dri/card2
fd = 4
IOCTL FAILED AND RETURNED ERROR : Invalid argument
[libevdi] ioctl: drop_master error=-1
Status of the node : AVAILABLE
Process id : 25308
Match found : 7f93f547f000-7f93f577f000 rw-s 100004000 00:06 463 /dev/dri/card2
fd = 5
IOCTL FAILED AND RETURNED ERROR : Invalid argument
[libevdi] ioctl: drop_master error=-1
Status of the EVDI handle : EVDI_VALID_HANDLE
Opening connections
Registering Buffers
Event Handler = 5

Event Handling Loop
No DATA to be read

Screen Update Status : TRUE
IOCTL FAILED AND RETURNED ERROR : Resource temporarily unavailable
[libevdi] ioctl: grabpix error=-1
[libevdi] Grabbing pixels for buffer 0 failed. Should be ignored if caused by change of mode in kernel.
Unregistering Buffers
Disconnecting
Closing devices



Thank you
Regards,
Irene
Irene is offline   Reply With Quote