Skip to content

Commit

Permalink
Merge pull request #52 from zouxiaoh/icamerasrc_slim_api
Browse files Browse the repository at this point in the history
ARL PV release for kernel v6.11-rc3
  • Loading branch information
zouxiaoh authored Sep 26, 2024
2 parents dd5cc0b + d8ff5b3 commit 1077dcb
Show file tree
Hide file tree
Showing 13 changed files with 72 additions and 76 deletions.
3 changes: 1 addition & 2 deletions autogen.sh
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,7 @@ autoreconf --verbose --force --install --make || {
exit 1;
}

args="--prefix=/usr \
--libdir=/usr/lib"
args="--prefix=/usr"

./configure $args || {
echo 'configure failed';
Expand Down
67 changes: 32 additions & 35 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,12 @@ AC_ARG_WITH([androidstubs],
AC_ARG_WITH([haladaptor],
AC_HELP_STRING([--with-haladaptor], [Link hal adaptor library [default=no]]))

AC_ARG_ENABLE([gstdrmformat],
AC_HELP_STRING([--enable-gstdrmformat], [Enable DRM format [default=no]]))

AC_ARG_ENABLE([internalbuild],
AC_HELP_STRING([--enable-internalbuild], [Internal build [default=no]]))

AC_ARG_VAR([DEFAULT_CAMERA],
[the default camera ID])

Expand Down Expand Up @@ -169,23 +175,12 @@ PKG_CHECK_MODULES(GST, [
])
])

if test "x$with_haladaptor" == "xyes"; then
echo Building with hal_adaptor
PKG_CHECK_MODULES(CAMHAL, [hal_adaptor], [
AC_SUBST(CAMHAL_CFLAGS)
AC_SUBST(CAMHAL_LIBS)
], [
AC_MSG_ERROR([Cannot find hal_adaptor pkgconfig])
])
else
echo Building with libcamhal
PKG_CHECK_MODULES(CAMHAL, [libcamhal], [
AC_SUBST(CAMHAL_CFLAGS)
AC_SUBST(CAMHAL_LIBS)
], [
AC_MSG_ERROR([Cannot find libcamhal pkgconfig])
])
fi
PKG_CHECK_MODULES(CAMHAL, [libcamhal], [
AC_SUBST(CAMHAL_CFLAGS)
AC_SUBST(CAMHAL_LIBS)
], [
AC_MSG_ERROR([Cannot find libcamhal pkgconfig])
])

PKG_CHECK_MODULES(LIBDRM, [libdrm libdrm_intel], [
AC_SUBST(LIBDRM_CFLAGS)
Expand All @@ -194,26 +189,28 @@ PKG_CHECK_MODULES(LIBDRM, [libdrm libdrm_intel], [
AC_MSG_ERROR([Cannot find libdrm pkgconfig])
])

PKG_CHECK_MODULES(LIBGSTREAMERVA, [gstreamer-va-1.0], [
AC_SUBST(LIBGSTREAMERVA_CFLAGS)
AC_SUBST(LIBGSTREAMERVA_LIBS)
], [
AC_MSG_WARN([Cannot find gstreamer-va-1.0 pkgconfig])
])
AS_IF([test "x$enable_gstdrmformat" = "xyes"], [
PKG_CHECK_MODULES(GST_1_23, [gstreamer-1.0 >= 1.23], [ have_gstdrmformat=yes ], [
PKG_CHECK_MODULES(GST_1_22_6, [gstreamer-1.0 = 1.22.6], [ have_gstdrmformat=yes ], [ have_gstdrmformat=no ])
])
PKG_CHECK_MODULES(LIBVA, [libva], [
AC_SUBST(LIBVA_CFLAGS)
AC_SUBST(LIBVA_LIBS)
], [
AC_MSG_WARN([Cannot find libva pkgconfig])
])
AS_IF([test "x$have_gstdrmformat" = "xyes"], [
PKG_CHECK_MODULES(DEP_GSTDRMFORMAT, [gstreamer-va-1.0 libva libva-drm], [
AC_SUBST(DEP_GSTDRMFORMAT_CFLAGS)
AC_SUBST(DEP_GSTDRMFORMAT_LIBS)
], [
have_gstdrmformat=no
AC_MSG_ERROR([Need gstreamer-va-1.0 libva libva-drm to enable GstVaDisplay])
])
], [
AC_MSG_ERROR([Need GStreamer >= 1.23 or == 1.22.6, and gstreamer-va-1.0 libva libva-drm to enable GstVaDisplay])
])
PKG_CHECK_MODULES(LIBVA_DRM, [libva-drm], [
AC_SUBST(LIBVA_DRM_CFLAGS)
AC_SUBST(LIBVA_DRM_LIBS)
], [
AC_MSG_WARN([Cannot find libva-drm pkgconfig])
])
AS_IF([test "x$have_gstdrmformat" = "xyes"], [
AC_DEFINE([GST_DRM_FORMAT], [1], [GStreamer at least 1.23 or exactly 1.22.6 supports DRM format])
AC_MSG_NOTICE(Define GST_DRM_FORMAT)
])
], [])

dnl check if compiler understands -Wall (if yes, add -Wall to GST_CFLAGS)
AC_MSG_CHECKING([to see if compiler understands -Wall])
Expand Down
8 changes: 2 additions & 6 deletions src/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -73,9 +73,7 @@ libgsticamerasrc_la_CPPFLAGS = \
$(GST_CFLAGS) \
$(CAMHAL_CFLAGS) \
$(LIBDRM_CFLAGS) \
$(LIBVA_CFLAGS) \
$(LIBVA_DRM_CFLAGS) \
$(LIBGSTREAMERVA_CFLAGS) \
$(DEP_GSTDRMFORMAT_CFLAGS) \
-std=c++11 \
-Werror \
$(LIBUTILS_CFLAGS) \
Expand All @@ -94,9 +92,7 @@ libgsticamerasrc_la_LIBADD = $(GST_LIBS) \
-lgstvideo-$(GST_API_VERSION) \
interfaces/libgsticamerainterface-$(GST_API_VERSION).la \
$(LIBDRM_LIBS) \
$(LIBVA_LIBS) \
$(LIBVA_DRM_LIBS) \
$(LIBGSTREAMERVA_LIBS) \
$(DEP_GSTDRMFORMAT_LIBS) \
$(CAMHAL_LIBS)

libgsticamerasrc_la_LDFLAGS = $(GST_PLUGIN_LDFLAGS)
Expand Down
8 changes: 4 additions & 4 deletions src/gstcambasesrc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
*/

#ifdef HAVE_CONFIG_H
# include <config.h>
#include <config.h>
#endif

#include "gstcambasesrc.h"
Expand Down Expand Up @@ -447,7 +447,7 @@ gst_cam_base_src_init(GstCamBaseSrc *basesrc, GstCamBaseSrcClass *klass)
gst_video_info_init(&basesrc->srcpad_info);
basesrc->is_info_change = FALSE;
#endif
#if GST_VERSION_MINOR == 22 && GST_VERSION_MICRO == 6 || GST_VERSION_MINOR >= 23
#ifdef GST_DRM_FORMAT
basesrc->is_dma_drm_caps = FALSE;
#endif

Expand Down Expand Up @@ -3738,13 +3738,13 @@ gst_cam_base_src_negotiate (GstCamBaseSrc * basesrc, GstPad *pad)

caps = gst_pad_get_current_caps (pad);

#if GST_VERSION_MINOR == 22 && GST_VERSION_MICRO == 6 || GST_VERSION_MINOR >= 23
#ifdef GST_DRM_FORMAT
basesrc->is_dma_drm_caps = gst_video_is_dma_drm_caps(caps);
#endif

#if GST_VERSION_MINOR >= 18
if (basesrc->is_info_change) {
#if GST_VERSION_MINOR == 22 && GST_VERSION_MICRO == 6 || GST_VERSION_MINOR >= 23
#ifdef GST_DRM_FORMAT
if (!CameraSrcUtils::gst_video_info_from_dma_drm_caps(&vinfo, caps))
#else
if (!gst_video_info_from_caps(&vinfo, caps))
Expand Down
2 changes: 1 addition & 1 deletion src/gstcambasesrc.h
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ struct _GstCamBaseSrc {
GstVideoInfo srcpad_info;
gboolean is_info_change;
#endif
#if GST_VERSION_MINOR == 22 && GST_VERSION_MICRO == 6 || GST_VERSION_MINOR >= 23
#ifdef GST_DRM_FORMAT
/* indicate current caps is dma_drm type for io_mode=dma_mode. */
bool is_dma_drm_caps;
#endif
Expand Down
2 changes: 1 addition & 1 deletion src/gstcameradeinterlace.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
#define LOG_TAG "GstCameraDeinterlace"

#ifdef HAVE_CONFIG_H
# include <config.h>
#include <config.h>
#endif

#include <sys/mman.h>
Expand Down
18 changes: 9 additions & 9 deletions src/gstcameraformat.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
#define LOG_TAG "GstCameraFormat"

#ifdef HAVE_CONFIG_H
# include <config.h>
#include <config.h>
#endif

#include <string.h>
Expand Down Expand Up @@ -93,7 +93,7 @@ static void update_main_resolution(int format,
cameraSrc_Res_Range res_range,
vector <cameraSrc_Main_Res_Range> &main_res_range);
static GstStructure *create_structure (guint32 fourcc);
#if GST_VERSION_MINOR == 22 && GST_VERSION_MICRO == 6 || GST_VERSION_MINOR >= 23
#ifdef GST_DRM_FORMAT
static void
set_structure_to_caps(vector<cameraSrc_Main_Res_Range> main_res_range,
GstCaps **caps, GstVaDisplay *display_drm);
Expand Down Expand Up @@ -179,7 +179,7 @@ create_structure (guint32 fourcc)
* Merge all structures into caps
*/
#define GST_CAPS_FEATURE_MEMORY_DMABUF "memory:DMABuf"
#if GST_VERSION_MINOR == 22 && GST_VERSION_MICRO == 6 || GST_VERSION_MINOR >= 23
#ifdef GST_DRM_FORMAT
static void
set_structure_to_caps(vector<cameraSrc_Main_Res_Range> main_res_range,
GstCaps **caps, GstVaDisplay *display_drm)
Expand All @@ -190,7 +190,7 @@ set_structure_to_caps(vector <cameraSrc_Main_Res_Range> main_res_range, GstCaps
{
GstStructure *structure = NULL;
int feature_index = 0;
#if GST_VERSION_MINOR == 22 && GST_VERSION_MICRO == 6 || GST_VERSION_MINOR >= 23
#ifdef GST_DRM_FORMAT
if (display_drm) {
/* Set caps with dmabuffer */
for (auto &res_range : main_res_range) {
Expand Down Expand Up @@ -390,7 +390,7 @@ GstCaps *gst_camerasrc_get_all_caps ()
if (caps != NULL && GST_IS_CAPS(caps)) {
return caps;
}
#if GST_VERSION_MINOR == 22 && GST_VERSION_MICRO == 6 || GST_VERSION_MINOR >= 23
#ifdef GST_DRM_FORMAT
GstVaDisplay *display_drm = NULL;
display_drm = gst_va_display_drm_new_from_path("/dev/dri/renderD128");
if (NULL == display_drm) {
Expand All @@ -407,7 +407,7 @@ GstCaps *gst_camerasrc_get_all_caps ()
int ret = get_camera_info(i, info);
if (ret != 0) {
g_printerr("failed to get camera info from libcamhal");
#if GST_VERSION_MINOR == 22 && GST_VERSION_MICRO == 6 || GST_VERSION_MINOR >= 23
#ifdef GST_DRM_FORMAT
if (display_drm) {
gst_object_unref(display_drm);
display_drm = NULL;
Expand All @@ -420,7 +420,7 @@ GstCaps *gst_camerasrc_get_all_caps ()
ret = register_format_and_resolution(configs, fmt_res, main_res_range);
if (ret != 0) {
g_printerr("failed to get format info from libcamhal");
#if GST_VERSION_MINOR == 22 && GST_VERSION_MICRO == 6 || GST_VERSION_MINOR >= 23
#ifdef GST_DRM_FORMAT
if (display_drm) {
gst_object_unref(display_drm);
display_drm = NULL;
Expand All @@ -431,14 +431,14 @@ GstCaps *gst_camerasrc_get_all_caps ()
}

caps = gst_caps_new_empty();
#if GST_VERSION_MINOR == 22 && GST_VERSION_MICRO == 6 || GST_VERSION_MINOR >= 23
#ifdef GST_DRM_FORMAT
set_structure_to_caps(main_res_range, &caps, display_drm);
#else
set_structure_to_caps(main_res_range, &caps);
#endif
caps = gst_caps_simplify(caps);
main_res_range.clear();
#if GST_VERSION_MINOR == 22 && GST_VERSION_MICRO == 6 || GST_VERSION_MINOR >= 23
#ifdef GST_DRM_FORMAT
if (display_drm) {
gst_object_unref(display_drm);
display_drm = NULL;
Expand Down
10 changes: 5 additions & 5 deletions src/gstcamerasrc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
#define LOG_TAG "GstCameraSrc"

#ifdef HAVE_CONFIG_H
# include <config.h>
#include <config.h>
#endif

#include <math.h>
Expand Down Expand Up @@ -1296,7 +1296,7 @@ gst_camerasrc_init (Gstcamerasrc * camerasrc)
camerasrc->streams[GST_CAMERASRC_MAIN_STREAM_ID].stream_config_done = FALSE;
camerasrc->streams[GST_CAMERASRC_MAIN_STREAM_ID].activated = TRUE;
camerasrc->streams[GST_CAMERASRC_MAIN_STREAM_ID].stream_usage = DEFAULT_PROP_SRC_STREAM_USAGE;
#if GST_VERSION_MINOR == 22 && GST_VERSION_MICRO == 6 || GST_VERSION_MINOR >= 23
#ifdef GST_DRM_FORMAT
camerasrc->streams[GST_CAMERASRC_MAIN_STREAM_ID].drm_modifier =
DRM_FORMAT_MOD_LINEAR;
#endif
Expand Down Expand Up @@ -2494,7 +2494,7 @@ gst_camerasrc_get_caps_info (Gstcamerasrc* camerasrc, GstCaps * caps, int stream
GstStructure *structure = gst_caps_get_structure (caps, 0);
const gchar *mimetype = gst_structure_get_name (structure);

#if GST_VERSION_MINOR == 22 && GST_VERSION_MICRO == 6 || GST_VERSION_MINOR >= 23
#ifdef GST_DRM_FORMAT
if (!gst_video_is_dma_drm_caps(caps)) {
#endif
/* raw caps, parse into video info */
Expand All @@ -2503,7 +2503,7 @@ gst_camerasrc_get_caps_info (Gstcamerasrc* camerasrc, GstCaps * caps, int stream
camerasrc->device_id, stream_id);
return FALSE;
}
#if GST_VERSION_MINOR == 22 && GST_VERSION_MICRO == 6 || GST_VERSION_MINOR >= 23
#ifdef GST_DRM_FORMAT
} else {
GstVideoInfoDmaDrm drm_info;
if (!gst_video_info_dma_drm_from_caps(&drm_info, caps)) {
Expand Down Expand Up @@ -2697,7 +2697,7 @@ gst_camerasrc_set_caps(GstCamBaseSrc *src, GstPad *pad, GstCaps *caps)

#if GST_VERSION_MINOR >= 18
if (camerasrc->io_mode == GST_CAMERASRC_IO_MODE_DMA_MODE) {
#if GST_VERSION_MINOR == 22 && GST_VERSION_MICRO == 6 || GST_VERSION_MINOR >= 23
#ifdef GST_DRM_FORMAT
if (CameraSrcUtils::gst_video_info_from_dma_drm_caps(&vinfo, caps)) {
#else
if (gst_video_info_from_caps(&vinfo, caps)) {
Expand Down
2 changes: 1 addition & 1 deletion src/gstcamerasrc.h
Original file line number Diff line number Diff line change
Expand Up @@ -463,7 +463,7 @@ struct _GstStreamInfo
/* Buffer config */
guint bpl;
GstVideoInfo info;
#if GST_VERSION_MINOR == 22 && GST_VERSION_MICRO == 6 || GST_VERSION_MINOR >= 23
#ifdef GST_DRM_FORMAT
/* drm modifier used currently after negotiated. */
guint64 drm_modifier;
#endif
Expand Down
16 changes: 8 additions & 8 deletions src/gstcamerasrcbufferpool.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
#define LOG_TAG "GstCameraSrcBufferPool"

#ifdef HAVE_CONFIG_H
# include <config.h>
#include <config.h>
#endif

#include <sys/mman.h>
Expand Down Expand Up @@ -141,7 +141,7 @@ gst_camerasrc_buffer_pool_finalize (GObject * object)
PERF_CAMERA_ATRACE();
GstCamerasrcBufferPool *pool = GST_CAMERASRC_BUFFER_POOL (object);
GST_INFO("CameraId=%d, StreamId=%d.", pool->src->device_id, pool->stream_id);
#if GST_VERSION_MINOR == 22 && GST_VERSION_MICRO == 6 || GST_VERSION_MINOR >= 23
#ifdef GST_DRM_FORMAT
if (pool->display_drm) {
gst_object_unref(pool->display_drm);
pool->display_drm = NULL;
Expand Down Expand Up @@ -178,7 +178,7 @@ gst_camerasrc_buffer_pool_init (GstCamerasrcBufferPool * pool)
pool->need_alignment = FALSE;
#endif

#if GST_VERSION_MINOR == 22 && GST_VERSION_MICRO == 6 || GST_VERSION_MINOR >= 23
#ifdef GST_DRM_FORMAT
pool->display_drm = NULL;
#endif
}
Expand All @@ -199,7 +199,7 @@ gst_camerasrc_buffer_pool_new (Gstcamerasrc *camerasrc,

if (camerasrc->io_mode == GST_CAMERASRC_IO_MODE_DMA_MODE) {
#if GST_VERSION_MINOR >= 18
#if GST_VERSION_MINOR == 22 && GST_VERSION_MICRO == 6 || GST_VERSION_MINOR >= 23
#ifdef GST_DRM_FORMAT
if (!CameraSrcUtils::gst_video_info_from_dma_drm_caps(&info, caps)) {
#else
if (!gst_video_info_from_caps(&info, caps)) {
Expand Down Expand Up @@ -291,7 +291,7 @@ gst_camerasrc_buffer_pool_set_config (GstBufferPool * bpool, GstStructure * conf
}

#if GST_VERSION_MINOR >= 18
#if GST_VERSION_MINOR == 22 && GST_VERSION_MICRO == 6 || GST_VERSION_MINOR >= 23
#ifdef GST_DRM_FORMAT
if (!CameraSrcUtils::gst_video_info_from_dma_drm_caps(&video_info, caps)) {
#else
if (!gst_video_info_from_caps (&video_info, caps)) {
Expand All @@ -313,7 +313,7 @@ gst_camerasrc_buffer_pool_set_config (GstBufferPool * bpool, GstStructure * conf
pool->allocator = NULL;

if (camerasrc->io_mode == GST_CAMERASRC_IO_MODE_DMA_EXPORT || camerasrc->io_mode == GST_CAMERASRC_IO_MODE_DMA_MODE) {
#if GST_VERSION_MINOR == 22 && GST_VERSION_MICRO == 6 || GST_VERSION_MINOR >= 23
#ifdef GST_DRM_FORMAT
if (NULL == pool->display_drm) {
pool->display_drm =
gst_va_display_drm_new_from_path("/dev/dri/renderD128");
Expand Down Expand Up @@ -693,7 +693,7 @@ gst_camerasrc_alloc_dma_mode(GstCamerasrcBufferPool *pool,
if ((*meta)->buffer == NULL)
return GST_FLOW_ERROR;

#if GST_VERSION_MINOR == 22 && GST_VERSION_MICRO == 6 || GST_VERSION_MINOR >= 23
#ifdef GST_DRM_FORMAT
if (!GST_CAM_BASE_SRC(src)->is_dma_drm_caps) {
#endif

Expand Down Expand Up @@ -747,7 +747,7 @@ gst_camerasrc_alloc_dma_mode(GstCamerasrcBufferPool *pool,
close(intel_fd);
drm_intel_bufmgr_destroy(bufmgr);
drm_intel_bo_unreference(drm_bo);
#if GST_VERSION_MINOR == 22 && GST_VERSION_MICRO == 6 || GST_VERSION_MINOR >= 23
#ifdef GST_DRM_FORMAT
} else {
if (NULL == pool->display_drm) {
GST_ERROR("Couldn't create a VA DRM display");
Expand Down
2 changes: 1 addition & 1 deletion src/gstcamerasrcbufferpool.h
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ struct _GstCamerasrcBufferPool
GstVideoAlignment alignment;
#endif

#if GST_VERSION_MINOR == 22 && GST_VERSION_MICRO == 6 || GST_VERSION_MINOR >= 23
#ifdef GST_DRM_FORMAT
/* operate on /dev/dri/renderD128 */
GstVaDisplay *display_drm;
#endif
Expand Down
Loading

0 comments on commit 1077dcb

Please sign in to comment.