xuesong.jiang | ae1548e | 2022-05-06 16:38:46 +0800 | [diff] [blame] | 1 | /* 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 | |
| 25 | G_BEGIN_DECLS |
| 26 | |
bo.xiao | 857b868 | 2024-09-12 16:40:32 +0800 | [diff] [blame^] | 27 | #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.jiang | ae1548e | 2022-05-06 16:38:46 +0800 | [diff] [blame] | 41 | |
| 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.xiao | 857b868 | 2024-09-12 16:40:32 +0800 | [diff] [blame^] | 57 | (V4L2_CAP_VIDEO_OUTPUT | V4L2_CAP_VIDEO_OUTPUT_MPLANE)))) |
xuesong.jiang | ae1548e | 2022-05-06 16:38:46 +0800 | [diff] [blame] | 58 | |
| 59 | typedef struct _GstAmlV4l2Iterator GstAmlV4l2Iterator; |
| 60 | typedef struct _GstAmlV4l2Error GstAmlV4l2Error; |
| 61 | |
| 62 | struct _GstAmlV4l2Iterator |
| 63 | { |
| 64 | const gchar *device_path; |
| 65 | const gchar *device_name; |
| 66 | const gchar *sys_path; |
| 67 | }; |
| 68 | |
| 69 | struct _GstAmlV4l2Error |
| 70 | { |
| 71 | GError *error; |
| 72 | gchar *dbg_message; |
| 73 | const gchar *file; |
| 74 | const gchar *func; |
| 75 | gint line; |
| 76 | }; |
| 77 | |
| 78 | GstAmlV4l2Iterator *gst_aml_v4l2_iterator_new(void); |
| 79 | gboolean gst_aml_v4l2_iterator_next(GstAmlV4l2Iterator *it); |
| 80 | void gst_aml_v4l2_iterator_free(GstAmlV4l2Iterator *it); |
| 81 | |
| 82 | const gchar *gst_aml_v4l2_iterator_get_device_path(GstAmlV4l2Iterator *it); |
| 83 | const gchar *gst_aml_v4l2_iterator_get_device_name(GstAmlV4l2Iterator *it); |
| 84 | const gchar *gst_aml_v4l2_iterator_get_sys_path(GstAmlV4l2Iterator *it); |
| 85 | |
| 86 | void gst_aml_v4l2_clear_error(GstAmlV4l2Error *error); |
| 87 | void gst_aml_v4l2_error(gpointer element, GstAmlV4l2Error *error); |
| 88 | |
| 89 | G_END_DECLS |
| 90 | |
| 91 | #endif /* __AML_V4L2_UTILS_H__ */ |