v4l2: Add a macro to check for M2M

https://bugzilla.gnome.org/show_bug.cgi?id=794842
This commit is contained in:
Nicolas Dufresne 2018-07-13 15:58:36 -04:00
parent 0649b0ab0f
commit 3735e57fb2
3 changed files with 20 additions and 14 deletions

View file

@ -153,12 +153,7 @@ gst_v4l2_probe_and_register (GstPlugin * plugin)
else
device_caps = vcap.capabilities;
if (!((device_caps & (V4L2_CAP_VIDEO_M2M | V4L2_CAP_VIDEO_M2M_MPLANE)) ||
/* But legacy driver may expose both CAPTURE and OUTPUT */
((device_caps &
(V4L2_CAP_VIDEO_CAPTURE | V4L2_CAP_VIDEO_CAPTURE_MPLANE)) &&
(device_caps &
(V4L2_CAP_VIDEO_OUTPUT | V4L2_CAP_VIDEO_OUTPUT_MPLANE)))))
if (!GST_V4L2_IS_M2M (device_caps))
continue;
GST_DEBUG ("Probing '%s' located at '%s'",

View file

@ -41,6 +41,24 @@ G_BEGIN_DECLS
} \
}
/**
* GST_V4L2_IS_M2M:
* @_dcaps: The device capabilities
*
* Checks if the device caps represent an M2M device. Note that modern M2M
* devices uses V4L2_CAP_VIDEO_M2M* flag, but legacy uses to set both CAPTURE
* and OUTPUT flags instead.
*
* Returns: %TRUE if this is a M2M device.
*/
#define GST_V4L2_IS_M2M(_dcaps) \
(((_dcaps) & (V4L2_CAP_VIDEO_M2M | V4L2_CAP_VIDEO_M2M_MPLANE)) ||\
(((_dcaps) & \
(V4L2_CAP_VIDEO_CAPTURE | V4L2_CAP_VIDEO_CAPTURE_MPLANE)) && \
((_dcaps) & \
(V4L2_CAP_VIDEO_OUTPUT | V4L2_CAP_VIDEO_OUTPUT_MPLANE))))
typedef struct _GstV4l2Iterator GstV4l2Iterator;
typedef struct _GstV4l2Error GstV4l2Error;

View file

@ -575,14 +575,7 @@ gst_v4l2_open (GstV4l2Object * v4l2object)
goto not_output;
if (GST_IS_V4L2_VIDEO_DEC (v4l2object->element) &&
/* Today's M2M device only expose M2M */
!((v4l2object->device_caps & (V4L2_CAP_VIDEO_M2M |
V4L2_CAP_VIDEO_M2M_MPLANE)) ||
/* But legacy driver may expose both CAPTURE and OUTPUT */
((v4l2object->device_caps &
(V4L2_CAP_VIDEO_CAPTURE | V4L2_CAP_VIDEO_CAPTURE_MPLANE)) &&
(v4l2object->device_caps &
(V4L2_CAP_VIDEO_OUTPUT | V4L2_CAP_VIDEO_OUTPUT_MPLANE)))))
!GST_V4L2_IS_M2M (v4l2object->device_caps))
goto not_m2m;
gst_v4l2_adjust_buf_type (v4l2object);