WFD_QNX_destination_acquire_image
WFD_QNX_destination_acquire_image
Description
Retrieve data generated by port writeback.
You need the following extensions:
- WFD_QNX_destination
- WFD_QNX_port_writeback
Examples
The following is an example of how to configure writeback:
/**
* This is the preferred way to get data generated by port writeback.
*
* It depends on the following extensions:
* - @c WFD_QNX_destination
* - @c WFD_QNX_port_writeback
*
* The following code shows how writeback could be configured:
* @anchor sample_writeback @code{.c}
#define WFD_WFDEXT_PROTOTYPES
#include <WF/wfd.h>
#include <WF/wfdext.h>
#include <assert.h>
#include <stddef.h>
#include <stdio.h>
#include <time.h>
struct wb_arg {
WFDDevice devhdl;
WFDPort porthdl;
WFDint width, height;
WFDEGLImage images[3];
};
void *writeback_thread(void *arg)
{
struct wb_arg *wb = arg;
WFDDestinationQNX desthdl;
__errno_t err;
WFDErrorCode wfderr;
//TODO: check for necessary extensions:
// - WFD_QNX_destination_create_from_images
// - WFD_QNX_port_writeback
// - WFD_QNX_destination
// - WFD_QNX_destination_acquire_image
// verify that the writeback is enabled on the port:
// - eg. wfdGetPortAttribi(device, port, WFD_PORT_WRITEBACK_SUPPORT_QNX)
// allocate image buffers
// fill the 'images' array
err = wfdCreateDestinationFromImagesQNX(wb->devhdl, 3, &wb->images[0], NULL, &desthdl);
if (err) { goto fail; }
wfderr = wfdBindDestinationToPortQNX(wb->devhdl, wb->porthdl, desthdl, WFD_TRANSITION_AT_VSYNC);
if (wfderr) { goto fail; }
wfdSetPortAttribiv(wb->devhdl, wb->porthdl, WFD_PORT_WRITEBACK_SOURCE_RECTANGLE_QNX,
4, (const WFDint[]){0, 0, wb->width, wb->height});
wfdSetPortAttribiv(wb->devhdl, wb->porthdl, WFD_PORT_WRITEBACK_DESTINATION_RECTANGLE_QNX,
4, (const WFDint[]){0, 0, wb->width, wb->height});
wfdDeviceCommit(wb->devhdl, WFD_COMMIT_ENTIRE_PORT, wb->porthdl);
wfderr = wfdGetError(wb->devhdl);
if (wfderr) { goto fail; }
for(;;) {
WFDint image_idx;
struct timespec endtime;
unsigned seqno;
if (0 != clock_gettime(CLOCK_MONOTONIC, &endtime)) { goto fail; }
endtime.tv_sec += 1;
// wait for the driver to write an image buffer
err = wfdAcquireDestinationImageQNX(wb->devhdl, desthdl, (const intptr_t[]){
WFD_TIMEOUT_ABS_MONOTONIC_QNX, (intptr_t)&endtime,
WFD_WRITEBACK_SEQUENCE_NUMBER_QNX, (intptr_t)&seqno,
WFD_NONE
}, &image_idx);
if (err) {
goto fail;
}
printf("got frame #%u from writeback\n", seqno);
//TODO: look for sequence number gaps, to detect missed frames
//TODO: use images[image_idx], possibly via WFD_QNX_egl_image_attrib
// release the buffer back to the driver, so it can write new
// data there if necessary
err = wfdReleaseDestinationImageQNX(wb->devhdl, desthdl, image_idx);
assert(!err);
}
// unbind the destination
wfderr = wfdBindDestinationToPortQNX(wb->devhdl, wb->porthdl, WFD_INVALID_HANDLE, WFD_TRANSITION_AT_VSYNC);
if (wfderr) { goto fail; }
wfdDeviceCommit(wb->devhdl, WFD_COMMIT_ENTIRE_PORT, wb->porthdl);
wfderr = wfdGetError(wb->devhdl);
if (wfderr) { goto fail; }
wfdDestroyDestinationQNX(wb->devhdl, desthdl);
return NULL;
fail:
; //TODO
}
* @endcode
*/
Page updated: