Hi,
I am using a simple graphics application VertexColors.c in gpu_sdk_v1.00 from freescale. It has main(), init(),render(),resize() as the function blocks. and the flow of calls is like
1.main() => init() (i.e. main() is calling init())
2.init() => resize()
3.after init(), main() => render()
and then eglSwapBuffers(egldisplay, eglsurface) is called.
And now to direct it to /dev/fb1 i assume i have to include:
int fd_fb,result;
//Applying color key
struct mxcfb_color_key color_key;
color_key.color_key = 0x0;
color_key.enable = 1;
if ((fd_fb = open("/dev/fb1", O_RDWR, 0)) < 0)
{
return 0;
}
if ( ioctl(fd_fb, MXCFB_SET_CLR_KEY, &color_key) < 0) {
printf("Error in applying Color Key\n");
}
struct mxcfb_loc_alpha loc_alpha;
ioctl(fd_fb, FBIOBLANK, FB_BLANK_NORMAL);
loc_alpha.enable = 1;
loc_alpha.alpha_in_pixel = 1;
result = ioctl(fd_fb, MXCFB_SET_LOC_ALPHA, &loc_alpha);
if (result < 0)
{
printf("fb ioctl MXCFB_SET_LOC_ALPHA fail\n");
//goto err1;
}
ioctl(fd_fb, MXCFB_WAIT_FOR_VSYNC, 0);
ioctl(fd_fb, FBIOBLANK, FB_BLANK_UNBLANK);
close(fd_fb);
Please correct me if i am wrong or if i am missing any details. But, i wonder where to include this piece of code in the given application.
Thanks in advance.
Sudlin
Send your post to imx community (e.g. i.MX Community ) to get it visible for active members.
Hi Saurabh,
But this discussion is open to everyone. So, is it not visible for active members?
I have posted it. Thanks.
Hi,
I know that Bio_TICFSL will be able to provide more information about this.
As far as I understand each frame buffer is tied to a display. Then I assume you want to display your graphic in a different display.
To do so, you need to enable the different display for example:
video=mxcfb0:dev=ldb,if=RGB666
video=mxcfb1:dev=hdmi,
1920x1080M@60,if=RGB24
Used when primarily displaying
on LVDS with XGA mode.
Secondarily displaying on HDMI
with 1080P60 mode
And DISPLAY evironment variable should be different than 0.0
Also as far as I understand using openGL you should not worry about the fb driver.
Bio_TICFSL if I am mistaken please let me know, do you have something else you can share?
Best Regards,
Alejandro
Hi,
Thanks Alejandro for your reply.
My problem is actually different than what you sensed from my Title.
I have to display the graphics on /dev/fb1 and a camera streaming on the background i.e. on /dev/fb0 at the same time (overlay on top of one another).
I am using lvds for display.so,parameters i am using are
video=mxcfb0:dev=ldb,if=RGB666.
Inside main(), i suppose i have to include both gstreamer APIs for camera streaming and graphics APIs for drawing .
************************************************************************************************************
////////////////******Graphics APIs for drawing onto /dev/fb1**********//////////////////
int main(int argc, char** argv)
{
printf("Lesson 03 \n");
int fd_fb,result;
//Applying color key
struct mxcfb_color_key color_key;
color_key.color_key = 0x0;
color_key.enable = 1;
if ((fd_fb = open("/dev/fb1", O_RDWR, 0)) < 0)
{
return 0;
}
if ( ioctl(fd_fb, MXCFB_SET_CLR_KEY, &color_key) < 0) {
printf("Error in applying Color Key\n");
}
struct mxcfb_loc_alpha loc_alpha;
ioctl(fd_fb, FBIOBLANK, FB_BLANK_NORMAL);
loc_alpha.enable = 1;
loc_alpha.alpha_in_pixel = 1;
result = ioctl(fd_fb, MXCFB_SET_LOC_ALPHA, &loc_alpha);
if (result < 0)
{
printf("fb ioctl MXCFB_SET_LOC_ALPHA fail\n");
//goto err1;
}
ioctl(fd_fb, MXCFB_WAIT_FOR_VSYNC, 0);
ioctl(fd_fb, FBIOBLANK, FB_BLANK_UNBLANK);
close(fd_fb);
signal(SIGINT, sighandler);
signal(SIGTERM, sighandler);
assert( init() );
while (!quit)
{
render();
eglSwapBuffers(egldisplay, eglsurface);
}
deinit();
return 1;
}
**********************************************************************************************
/////////////////////************Gstreamer APIs for video streaming onto /dev/fb0**********//////////////
GstElement *pipeline, *source, *sink;
GstBus *bus;
GstMessage *msg;
GstStateChangeReturn ret;
/* Initialize GStreamer */
gst_init (&argc, &argv);
/* Create the elements */
source = gst_element_factory_make ("mfw_v4lsrc", "source");
sink = gst_element_factory_make ("mfw_v4lsink", "sink");
/* Create the empty pipeline */
pipeline = gst_pipeline_new ("test-pipeline");
if (!pipeline || !source || !sink) {
g_printerr ("Not all elements could be created.\n");
return -1;
}
/* Build the pipeline */
gst_bin_add_many (GST_BIN (pipeline), source, sink, NULL);
if (gst_element_link (source, sink) != TRUE) {
g_printerr ("Elements could not be linked.\n");
gst_object_unref (pipeline);
return -1;
}
/* Modify the source's properties */
g_object_set (source, "device", "/dev/video2", NULL);
/* Start playing */
ret = gst_element_set_state (pipeline, GST_STATE_PLAYING);
if (ret == GST_STATE_CHANGE_FAILURE) {
g_printerr ("Unable to set the pipeline to the playing state.\n");
gst_object_unref (pipeline);
return -1;
}
/* Wait until error or EOS */
bus = gst_element_get_bus (pipeline);
msg = gst_bus_timed_pop_filtered (bus, GST_CLOCK_TIME_NONE, GST_MESSAGE_ERROR | GST_MESSAGE_EOS);
/* Parse message */
if (msg != NULL) {
GError *err;
gchar *debug_info;
switch (GST_MESSAGE_TYPE (msg)) {
case GST_MESSAGE_ERROR:
gst_message_parse_error (msg, &err, &debug_info);
g_printerr ("Error received from element %s: %s\n", GST_OBJECT_NAME (msg->src), err->message);
g_printerr ("Debugging information: %s\n", debug_info ? debug_info : "none");
g_clear_error (&err);
g_free (debug_info);
break;
case GST_MESSAGE_EOS:
g_print ("End-Of-Stream reached.\n");
break;
default:
/* We should not reach here because we only asked for ERRORs and EOS */
g_printerr ("Unexpected message received.\n");
break;
}
gst_message_unref (msg);
}
/* Free resources */
gst_object_unref (bus);
gst_element_set_state (pipeline, GST_STATE_NULL);
gst_object_unref (pipeline);
return 0;
}
*********************************************************************************************************************
So, will both of them directed to their respective framebuffers and overlayed if i incude them in main( ) or will i have to do some modifications in the code to achieve this?
And is there any way to verify which framebuffer is being used while an applcation is running?
It would be highly appreciable if you help me regarding this.
With regards,
Sudlin
This application uses EGL APIs to display the graphics.
I went through the following freescale thread
https://community.freescale.com/thread/297663
and changed the parameter to "1" to display it on /dev/fb1 but after compiling the code, the graphics is not displayed on the screen unlike it normally works fine on /dev/fb0.