hello everyone, i have some trouble in imx6q about ui and video combining.
i'm using buildroot for system (kernel 3.10 + QT5.5 + eglfs2.0 ). i want to play video and show transparent picture(eg: png) on the top of video.
my kernel boot args:"video=mxcfb0:dev=hdmi,1920x1080@60,if=RGB24,bpp=32 "
i have try some methods like this :
set video output to "video16"(BG),and set QT output to "fb1"(FG), this can work, but the background of "fb1" is not transparent and "fb1" have covered the video.
i tried to set the background of qt widget to transparent and set the "alpha"and"color_key" of fb1 device, but no effect both,or the settings is wrong ?
i also tried to set video output to "video16"(BG),and set QT output to "fb0"(BG), it will just show video only.
i can't find any demos for this, is there any method for my purpose ?
i'm look forward to you, thanks.
已解决! 转到解答。
the packet i used is at version 3.10.53, and at this version, the gstreamer-0.10 can not solve my problem. i must use gstreamer-1.0. now, i can draw transparent pictures on video and it looks perfect. thanks anyway, i wish this discussion can help someone else.
Supplementary description:
the fb1 device is not as 1920x1080@60 resolution after kernel start up.
# fbset -s -fb /dev/fb0
mode "1920x1080-60"
# D: 148.500 MHz, H: 67.500 kHz, V: 60.000 Hz
geometry 1920 1080 1920 1080 32
timings 6734 148 88 36 4 44 5
accel false
rgba 8/16,8/8,8/0,8/24
endmode
#
# fbset -s -fb /dev/fb1
mode "240x320-60"
# D: 4.608 MHz, H: 19.200 kHz, V: 60.000 Hz
geometry 240 320 240 960 16
timings 217013 0 0 0 0 0 0
accel false
rgba 5/11,6/5,5/0,0/0
endmode
#
i try to set fb1 to the same as fb0 like this:
struct fb_var_screeninfo var;
/* set fb1 */
ret = ioctl( fd_fb0, FBIOGET_VSCREENINFO, &var );
if( ret < 0 ){
printf( "ioctl %s FBIOGET_VSCREENINFO failed\n", fb_dev_path[FB_0] );
goto err;
}
var.activate = FB_ACTIVATE_FORCE;
ret = ioctl( fd_fb1, FBIOPUT_VSCREENINFO, &var );
if( ret < 0 ){
printf( "ioctl %s FBIOPUT_VSCREENINFO failed\n", fb_dev_path[FB_1] );
goto err;
}
is there any demos or documents about UI and video mixing ?
Here is an example to config frame buffer for alpha in pixel function, you can have a try.
retval = ioctl(fd, FBIOGET_VSCREENINFO, &fb_var);
if (retval < 0)
{
printf("fb ioctl FBIOGET_VSCREENINFO fail\n");
}
fb_var.xres = 1280;
fb_var.yres = 720;
fb_var.bits_per_pixel = 32;
fb_var.activate |= FB_ACTIVATE_FORCE;
fb_var.nonstd = v4l2_fourcc('A', 'B', 'G', 'R');
fb_var.red.offset = 24;
fb_var.red.length = 8;
fb_var.green.offset = 16;
fb_var.green.length = 8;
fb_var.blue.offset = 8;
fb_var.blue.length = 8;
fb_var.transp.offset = 0;
fb_var.transp.length = 8;
fb_var.xres_virtual = fb_var.xres;
fb_var.yres_virtual = fb_var.yres * 3;
fb_var.yoffset = 0;
retval = ioctl(fd, FBIOPUT_VSCREENINFO, &fb_var);
if (retval < 0)
{
printf("fb ioctl FBIOPUT_VSCREENINFO fail\n");
}
loc_alpha.enable = 1;
loc_alpha.alpha_in_pixel = 1;
retval = ioctl(fd, MXCFB_SET_LOC_ALPHA, &loc_alpha);
if (retval < 0)
{
printf("fb ioctl MXCFB_SET_LOC_ALPHA fail\n");
}
ioctl(fd, MXCFB_WAIT_FOR_VSYNC, 0);
ioctl(fd, FBIOBLANK, FB_BLANK_UNBLANK);
the packet i used is at version 3.10.53, and at this version, the gstreamer-0.10 can not solve my problem. i must use gstreamer-1.0. now, i can draw transparent pictures on video and it looks perfect. thanks anyway, i wish this discussion can help someone else.
thanks for reminding me modify your sample code.
this is part of my code below:
retval = ioctl(fb1, FBIOGET_VSCREENINFO, &fb_var);
...
fb_var.xres = 1920;
fb_var.yres = 1080;
fb_var.bits_per_pixel = 32;
fb_var.activate |= FB_ACTIVATE_FORCE;
fb_var.nonstd = v4l2_fourcc('B', 'G', 'R','A');
fb_var.red.offset = 16;
fb_var.red.length = 8;
fb_var.green.offset = 8;
fb_var.green.length = 8;
fb_var.blue.offset = 0;
fb_var.blue.length = 8;
fb_var.transp.offset = 24;
fb_var.transp.length = 8;
fb_var.xres_virtual = fb_var.xres;
fb_var.yres_virtual = fb_var.yres * 3;
fb_var.yoffset = 0;
retval = ioctl(fb1, FBIOPUT_VSCREENINFO, &fb_var);
...
loc_alpha.enable = 1;
loc_alpha.alpha_in_pixel = 1;
retval = ioctl(fb1, MXCFB_SET_LOC_ALPHA, &loc_alpha);
...
ioctl(fb1, MXCFB_WAIT_FOR_VSYNC, 0);
ioctl(fb1, FBIOBLANK, FB_BLANK_UNBLANK);
after running this code, the background is black still.
the fb1 settings is :
# fbset -fb /dev/fb1 -s
mode "1920x1080-2"
# D: 4.608 MHz, H: 2.400 kHz, V: 2.222 Hz
geometry 1920 1080 1920 2160 32
timings 217013 0 0 0 0 0 0
accel false
rgba 8/16,8/8,8/0,8/24
endmode
#
and some settings of fb0 is changed.
before running, the settings of fb0 is :
# fbset -s -fb /dev/fb0
mode "1920x1080-60"
# D: 148.500 MHz, H: 67.500 kHz, V: 60.000 Hz
geometry 1920 1080 1920 1080 32
timings 6734 148 88 36 4 44 5
accel false
rgba 8/16,8/8,8/0,8/24
endmode
#
after, it is :
# fbset -fb /dev/fb0 -s
mode "1920x1080-60"
# D: 148.500 MHz, H: 67.500 kHz, V: 60.000 Hz
geometry 1920 1080 1920 3240 16
timings 6734 148 88 36 4 44 5
accel false
rgba 5/11,6/5,5/0,0/0
endmode
#
the "bpp" ,"vyres" "rgba" is changed .
i also tried to copy all settings of fb0 to fb1, it worked the same.
"the background of "fb1" is not transparent" means there is a black background on the top of video, even though i set the background of qt window to transparent.
for example:
i want to show a qt window (which draw a png picture )on the top of video, but actually the background of window is black.
i set the background of qt window to transparent with this code :
"
void MainWindow::paintEvent(QPaintEvent *e)
{
QPainter p(this);
p.setCompositionMode( QPainter::CompositionMode_Clear );
p.fillRect( this->rect(), Qt::SolidPattern );
}
"
i also tried this:
QPalette pal = palette();
pal.setColor(QPalette::Background, QColor(0x00,0x00,0x00,0x00));//
setPalette(pal);
but no effect,the background of window is also black.
at the internet, i find some way (setting the alpha and color_key of fb device )like this:
int fd = 0,ret = 0;
struct mxcfb_gbl_alpha gbl_alpha;
gbl_alpha.alpha = 0;
gbl_alpha.enable = 1;
if ((fd = open("/dev/fb1", O_RDWR)) < 0){
printf("Unable to open /dev/fb1 !!!\n");
return;
}
ret = ioctl(fd, MXCFB_SET_GBL_ALPHA, &gbl_alpha);
if(ret <0) {
printf("Error!MXCFB_SET_GBL_ALPHA failed!");
return;
}
struct mxcfb_color_key key;
key.enable = 1;
key.color_key = 0x00000000; // Black
ret = ioctl(fd, MXCFB_SET_CLR_KEY, &key);
if(ret <0) {
printf("Error!Colorkey setting failed for dev ");
return;
}
but also no effect,and will take some errors about IPU sometime.
is the imx6q platform not support this function or need some patches?
thanks a lot
i have tried this approach from the link "[solved] how to get an simple transparent window | Qt Forum" you told me, but it doesn't work.
i think the problem can not be solved by QT only, because it related to mix of two framebuffers. it should depend on IMX6Q platform.
the key is that there is no demo or doc about this. i have touched to the FAE of freescale, they hav't replied yet.
thanks again.