Helloworld sample for g2d

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Helloworld sample for g2d

2,246 Views
dan_searles
Contributor I

Hello,

Would anyone be able to supply a yocto recipe for a simple 'hello world' like application, that can access the G2D API?

I have such a recipe to build a simple gstreamer application, but so far, I have not been able to figure out how to include the depends/links that would allow including access to the G2D api.

Ex: here is the recipe for the gstreamer recipe/application that works fine:

gstreamer1.0-app_1.0.0.bb:

SMMARY = "GStreamer app-1.0.0"
DESCRIPTION = "Gstreamer app-1.0.0"
SECTION = "apps"

inherit pkgconfig

DEPENDS = "glib-2.0 gstreamer1.0"
RDEPENDS_${PN} = "gstreamer1.0-plugins-base gstreamer1.0-plugins-good"

LICENSE = "MIT"
LIC_FILES_CHKSUM = "file://${COMMON_LICENSE_DIR}/MIT;md5=0835ade698e0bcf8506ecda2f7b4f302"

FILESEXTRAPATHS_prepend := "${THISDIR}/files:"

SRC_URI += " \
file://. \
"

inherit pkgconfig

do_compile() {
${CXX} ${WORKDIR}/gst-app_1.cpp -o gst-app_1 ${CXXFLAGS} ${LDFLAGS} `pkg-config --cflags --libs gstreamer-1.0`
}

do_install() {
install -d ${D}${bindir}/
install -m 0755 ${S}/gst-app_1 ${D}${bindir}/
}

FILES_${PN} += " \
${bindir}/ \
"

And in that dir, ./gstreamer1.0-app/gst-app_1.cpp contains:

#include <gst/gst.h>

int main(int argc, char *argv[]) {
GstElement *pipeline;
GstBus *bus;
GstMessage *msg;

/* Initialize GStreamer */
gst_init (&argc, &argv);

/* Build the pipeline */
pipeline = gst_parse_launch ("videotestsrc ! waylandsink name=mysink", NULL);

/* Start playing */
gst_element_set_state (pipeline, GST_STATE_PLAYING);

/* Wait until error or EOS */
bus = gst_element_get_bus (pipeline);
msg = gst_bus_timed_pop_filtered (bus, GST_CLOCK_TIME_NONE, GstMessageType(GST_MESSAGE_ERROR | GST_MESSAGE_EOS) );

/* Free resources */
if (msg != NULL)
gst_message_unref (msg);
gst_object_unref (bus);
gst_element_set_state (pipeline, GST_STATE_NULL);
gst_object_unref (pipeline);
return 0;
}

So instead of a gstreamer app, I would like to build an app source code file that uses G2D instead, like:

g2d-app_1.cpp:

#include "g2d.h"

int main(int argc, char *argv[]) {
void* handle;
g2d_open(&handle);

g2d_close(handle);
return 0;
}

So far, I just get errors that look like this:

Log data follows:
| DEBUG: Executing shell function do_compile
| /tmp/cciBbzfE.o: In function `main':
| ...gst-app_1.cpp:4: undefined reference to `g2d_open'
| ...gst-app_1.cpp:5: undefined reference to `g2d_close'
| collect2: error: ld returned 1 exit status
| WARNING: exit code 1 from a shell command.
| ERROR: Function failed: do_compile

Thanks

0 Kudos
4 Replies

1,761 Views
dan_searles
Contributor I

I have see those references and they do not answer the question I am asking.

Is it the case that there is no way to reference the g2d API from a recipe as I am asking?

0 Kudos

1,761 Views
radhikasomaiya
Senior Contributor II

Hi Dan Searles,

We can able to compile the g2d based application successfully in yocto_sumo.

Here is the .bb file that we are using :

SUMMARY = "Simple helloworld application"
SECTION = "examples"
inherit pkgconfig
DEPENDS = "glib-2.0 virtual/libg2d"
LICENSE = "MIT"
LIC_FILES_CHKSUM = "file://${COMMON_LICENSE_DIR}/MIT;md5=0835ade698e0bcf8506ecda2f7b4f302"
SRC_URI = "file://helloworld.c"
S = "${WORKDIR}"
do_compile() {
             ${CC} helloworld.c -o helloworld_new -lg2d
}

do_install() {
             install -d ${D}${bindir}
             install -m 0755 helloworld ${D}${bindir}
}

You can try with this. We don't know which version of yocto you are using. Let us know if you want us to run g2d application on a specific version.

Regards,

Radhika Somaiya

0 Kudos

1,761 Views
dan_searles
Contributor I

Thanks

The g2d lib being referenced as 'virtual/libg2d' indicates that there may be other means of being provided. On my platform, it ended up being through recipe imx-dpu-g2d (vs imx-gpu-g2d). In the future, -lg2d may be the way to link the library regardless, but at the moment, I needed -lg2d-dpu -ldrm, and I had to add 'drm' to the end of the DEPENDS. Also in the future, it seems likely that a '.pc' package file may be used to make the reference more generic.

0 Kudos

1,761 Views
b36401
NXP Employee
NXP Employee

Please refer to chapter 8.2 G2D-imx-samples of i.MX Linux® User's Guide.
Also please refer Yuri's thread regarding to g2d example:
https://community.nxp.com/thread/382621#comment-609269

0 Kudos