blob: 2586e18f7ed5aab1ece7644f41a0a2f4c9a645fa [file] [log] [blame]
xuesong.jiangae1548e2022-05-06 16:38:46 +08001/* GStreamer
2 * Copyright (C) 2022 <xuesong.jiang@amlogic.com>
3 *
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Library General Public
6 * License as published by the Free Software Foundation; either
7 * version 2 of the License, or (at your option) any later version.
8 *
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Library General Public License for more details.
13 *
14 * You should have received a copy of the GNU Library General Public
15 * License along with this library; if not, write to the
16 * Free Software Foundation, Inc., 51 Franklin Street, Suite 500,
17 * Boston, MA 02110-1335, USA.
18 */
19
20#ifndef __AML_V4L2_UTILS_H__
21#define __AML_V4L2_UTILS_H__
22
23#include <gst/gst.h>
24
25G_BEGIN_DECLS
26
bo.xiao857b8682024-09-12 16:40:32 +080027#define GST_AML_V4L2_ERROR_INIT { NULL, NULL }
28#define GST_AML_V4L2_ERROR(v4l2err,domain,code,msg,dbg) \
29{\
30 if (v4l2err) { \
31 gchar *_msg = _gst_element_error_printf msg; \
32 v4l2err->error = g_error_new_literal (GST_##domain##_ERROR, \
33 GST_##domain##_ERROR_##code, _msg); \
34 g_free (_msg); \
35 v4l2err->dbg_message = _gst_element_error_printf dbg; \
36 v4l2err->file = __FILE__; \
37 v4l2err->func = GST_FUNCTION; \
38 v4l2err->line = __LINE__; \
39 } \
40}
xuesong.jiangae1548e2022-05-06 16:38:46 +080041
42/**
43 * GST_AML_V4L2_IS_M2M:
44 * @_dcaps: The device capabilities
45 *
46 * Checks if the device caps represent an M2M device. Note that modern M2M
47 * devices uses V4L2_CAP_VIDEO_M2M* flag, but legacy uses to set both CAPTURE
48 * and OUTPUT flags instead.
49 *
50 * Returns: %TRUE if this is a M2M device.
51 */
52#define GST_AML_V4L2_IS_M2M(_dcaps) \
53 (((_dcaps) & (V4L2_CAP_VIDEO_M2M | V4L2_CAP_VIDEO_M2M_MPLANE)) ||\
54 (((_dcaps) & \
55 (V4L2_CAP_VIDEO_CAPTURE | V4L2_CAP_VIDEO_CAPTURE_MPLANE)) && \
56 ((_dcaps) & \
bo.xiao857b8682024-09-12 16:40:32 +080057 (V4L2_CAP_VIDEO_OUTPUT | V4L2_CAP_VIDEO_OUTPUT_MPLANE))))
xuesong.jiangae1548e2022-05-06 16:38:46 +080058
59typedef struct _GstAmlV4l2Iterator GstAmlV4l2Iterator;
60typedef struct _GstAmlV4l2Error GstAmlV4l2Error;
61
62struct _GstAmlV4l2Iterator
63{
64 const gchar *device_path;
65 const gchar *device_name;
66 const gchar *sys_path;
67};
68
69struct _GstAmlV4l2Error
70{
71 GError *error;
72 gchar *dbg_message;
73 const gchar *file;
74 const gchar *func;
75 gint line;
76};
77
78GstAmlV4l2Iterator *gst_aml_v4l2_iterator_new(void);
79gboolean gst_aml_v4l2_iterator_next(GstAmlV4l2Iterator *it);
80void gst_aml_v4l2_iterator_free(GstAmlV4l2Iterator *it);
81
82const gchar *gst_aml_v4l2_iterator_get_device_path(GstAmlV4l2Iterator *it);
83const gchar *gst_aml_v4l2_iterator_get_device_name(GstAmlV4l2Iterator *it);
84const gchar *gst_aml_v4l2_iterator_get_sys_path(GstAmlV4l2Iterator *it);
85
86void gst_aml_v4l2_clear_error(GstAmlV4l2Error *error);
87void gst_aml_v4l2_error(gpointer element, GstAmlV4l2Error *error);
88
89G_END_DECLS
90
91#endif /* __AML_V4L2_UTILS_H__ */