Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add rescaled screen detection and screen1 (/dev/fb1) support #20

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions README
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,7 @@ This partly breaks X11 integration due to hardware limitations. The video
area can't be overlapped by other windows. For fullscreen use this is no
problem.
Note: this needs G2D, so make sure that you have write access to /dev/g2d.

You can play video on second screen (when using separate framebuffer on /dev/fb1) with VDPAU_SCREEN
enviroment variable.
$ export VDPAU_SCREEN=1
8 changes: 8 additions & 0 deletions device.c
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,14 @@ VdpStatus vdp_imp_device_create_x11(Display *display,
VDPAU_DBG("Failed to open /dev/g2d! OSD disabled.");
}

char *env_vdpau_screen=getenv("VDPAU_SCREEN");
if(env_vdpau_screen)
{
dev->screen_i=atoi(env_vdpau_screen);
}
else
dev->screen_i=0;

int handle = handle_create(dev);
if (handle == -1)
{
Expand Down
33 changes: 24 additions & 9 deletions presentation_queue.c
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ VdpStatus vdp_presentation_queue_target_create_x11(VdpDevice device,

qt->drawable = drawable;
qt->fd = open("/dev/disp", O_RDWR);
qt->screen_i=dev->screen_i;
if (qt->fd == -1)
{
free(qt);
Expand All @@ -67,7 +68,21 @@ VdpStatus vdp_presentation_queue_target_create_x11(VdpDevice device,
return VDP_STATUS_ERROR;
}

uint32_t args[4] = { 0, DISP_LAYER_WORK_MODE_SCALER, 0, 0 };
__disp_layer_info_t layer_info;
uint32_t args[4] = { dev->screen_i, 100, &layer_info, 0 };
qt->sc_src_width=1;
qt->sc_src_height=1;
qt->sc_width=1;
qt->sc_height=1;
if(ioctl(qt->fd, DISP_CMD_LAYER_GET_PARA, args)>=0&&layer_info.mode==DISP_LAYER_WORK_MODE_SCALER)
{
qt->sc_src_width=layer_info.src_win.width;
qt->sc_src_height=layer_info.src_win.height;
qt->sc_width=layer_info.scn_win.width;
qt->sc_height=layer_info.scn_win.height;
}
args[1]=DISP_LAYER_WORK_MODE_SCALER;
args[2]=0;
qt->layer = ioctl(qt->fd, DISP_CMD_LAYER_REQUEST, args);
if (qt->layer == 0)
goto out_layer;
Expand Down Expand Up @@ -127,7 +142,7 @@ VdpStatus vdp_presentation_queue_target_destroy(VdpPresentationQueueTarget prese
if (!qt)
return VDP_STATUS_INVALID_HANDLE;

uint32_t args[4] = { 0, qt->layer, 0, 0 };
uint32_t args[4] = { qt->screen_i, qt->layer, 0, 0 };
ioctl(qt->fd, DISP_CMD_LAYER_CLOSE, args);
ioctl(qt->fd, DISP_CMD_LAYER_RELEASE, args);

Expand Down Expand Up @@ -303,10 +318,10 @@ VdpStatus vdp_presentation_queue_display(VdpPresentationQueue presentation_queue
layer_info.src_win.y = os->video_src_rect.y0;
layer_info.src_win.width = os->video_src_rect.x1 - os->video_src_rect.x0;
layer_info.src_win.height = os->video_src_rect.y1 - os->video_src_rect.y0;
layer_info.scn_win.x = x + os->video_dst_rect.x0;
layer_info.scn_win.y = y + os->video_dst_rect.y0;
layer_info.scn_win.width = os->video_dst_rect.x1 - os->video_dst_rect.x0;
layer_info.scn_win.height = os->video_dst_rect.y1 - os->video_dst_rect.y0;
layer_info.scn_win.x = x*q->target->sc_width/q->target->sc_src_width + (os->video_dst_rect.x0)*q->target->sc_width/q->target->sc_src_width;
layer_info.scn_win.y = y*q->target->sc_height/q->target->sc_src_height + os->video_dst_rect.y0*q->target->sc_height/q->target->sc_src_height;
layer_info.scn_win.width = (os->video_dst_rect.x1 - os->video_dst_rect.x0)*q->target->sc_width/q->target->sc_src_width;
layer_info.scn_win.height = (os->video_dst_rect.y1 - os->video_dst_rect.y0)*q->target->sc_height/q->target->sc_src_height;
layer_info.ck_enable = q->device->osd_enabled ? 0 : 1;

if (layer_info.scn_win.y < 0)
Expand All @@ -318,7 +333,7 @@ VdpStatus vdp_presentation_queue_display(VdpPresentationQueue presentation_queue
layer_info.scn_win.height -= cutoff;
}

uint32_t args[4] = { 0, q->target->layer, (unsigned long)(&layer_info), 0 };
uint32_t args[4] = { q->device->screen_i, q->target->layer, (unsigned long)(&layer_info), 0 };
ioctl(q->target->fd, DISP_CMD_LAYER_SET_PARA, args);

ioctl(q->target->fd, DISP_CMD_LAYER_OPEN, args);
Expand All @@ -344,7 +359,7 @@ VdpStatus vdp_presentation_queue_display(VdpPresentationQueue presentation_queue
}
else
{
uint32_t args[4] = { 0, q->target->layer, 0, 0 };
uint32_t args[4] = { q->device->screen_i, q->target->layer, 0, 0 };
ioctl(q->target->fd, DISP_CMD_LAYER_CLOSE, args);
}

Expand Down Expand Up @@ -381,7 +396,7 @@ VdpStatus vdp_presentation_queue_display(VdpPresentationQueue presentation_queue
layer_info.scn_win.width = clip_width ? clip_width : os->width;
layer_info.scn_win.height = clip_height ? clip_height : os->height;

uint32_t args[4] = { 0, q->target->layer_top, (unsigned long)(&layer_info), 0 };
uint32_t args[4] = { q->target->screen_i, q->target->layer_top, (unsigned long)(&layer_info), 0 };
ioctl(q->target->fd, DISP_CMD_LAYER_SET_PARA, args);

ioctl(q->target->fd, DISP_CMD_LAYER_OPEN, args);
Expand Down
6 changes: 6 additions & 0 deletions vdpau_private.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ typedef struct
int fd;
int g2d_fd;
int osd_enabled;
int screen_i;
} device_ctx_t;

typedef struct video_surface_ctx_struct
Expand Down Expand Up @@ -70,6 +71,11 @@ typedef struct
int fd;
int layer;
int layer_top;
int sc_src_width;
int sc_src_height;
int sc_width;
int sc_height;
int screen_i;
} queue_target_ctx_t;

typedef struct
Expand Down