Пример #1
0
uint32_t allocate_and_set_vc_handle(gralloc_private_handle_t *private_handle) {
    uint32_t vc_handle = 0;
    DISPMANX_RESOURCE_HANDLE_T resource_handle = vc_dispmanx_resource_create(
            convert_android_to_vc_img_type(private_handle->pixel_format), private_handle->w, private_handle->h,
            &vc_handle);

    //vc_dispmanx_resource_create set vc_handle to 0
    //call to vc_dispmanx_resource_get_image_handle is needed
    vc_handle = vc_dispmanx_resource_get_image_handle(resource_handle);

    return vc_handle;
}
Пример #2
0
void dispmanxtest() {
	DISPMANX_DISPLAY_HANDLE_T display;
	int ret;
	DISPMANX_MODEINFO_T displayinfo;
	DISPMANX_RESOURCE_HANDLE_T res;
	int width = 1024;
	int height = 576;
	uint32_t vc_image_ptr;
	DISPMANX_UPDATE_HANDLE_T update;
	VC_RECT_T dst_rect,src_rect;
	DISPMANX_ELEMENT_HANDLE_T element;

	
	bcm_host_init();
	display = vc_dispmanx_display_open(0);
	ret = vc_dispmanx_display_get_info( display, &displayinfo);
	assert(ret==0);
	printf("display is %dx%d\n",displayinfo.width,displayinfo.height);
	res = vc_dispmanx_resource_create(VC_IMAGE_YUV420,width,height,&vc_image_ptr);
	vc_image_ptr = vc_dispmanx_resource_get_image_handle(res);
	printf("vc_image_ptr %x\n",vc_image_ptr);
	assert(res);
	update = vc_dispmanx_update_start(10);
	assert(update);
	vc_dispmanx_rect_set(&src_rect,0,0,width<<16,height<<16);
	vc_dispmanx_rect_set(&dst_rect,0,(displayinfo.height - height)/2,width-32,height);
	element = vc_dispmanx_element_add(update,display,2000,&dst_rect,res,&src_rect,DISPMANX_PROTECTION_NONE,NULL,NULL,DISPMANX_NO_ROTATE);
	ret = vc_dispmanx_update_submit_sync(update);
	assert(ret==0);
	uint8_t *rawfb = (uint8_t*)mapmem(vc_image_ptr,0x1000);
	for (int i=0; i<0x100; i++) {
		printf("%02x ",rawfb[i]);
	}
	printf("\n");
	unmapmem(rawfb,0x1000);
	puts("sleeping");
	sleep(10);
	update = vc_dispmanx_update_start(10);
	assert(update);
	ret = vc_dispmanx_element_remove(update,element);
	assert(ret==0);
	ret = vc_dispmanx_update_submit_sync(update);
	assert(ret==0);
	ret = vc_dispmanx_resource_delete(res);
	assert(ret==0);
	ret = vc_dispmanx_display_close(display);
	assert(ret==0);
}