From: Sebastian Dröge Date: Wed, 2 Jan 2013 13:16:06 +0000 (+0100) Subject: mfc: Check device capabilities before doing anything else X-Git-Tag: 1.19.3~507^2~14276 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=83a8138b4ae2863f8ac1703ec6042a7ddb3fa9a4;p=platform%2Fupstream%2Fgstreamer.git mfc: Check device capabilities before doing anything else --- diff --git a/sys/mfc/mfc_decoder/mfc_decoder.c b/sys/mfc/mfc_decoder/mfc_decoder.c index c835f0d362..9070920d9d 100644 --- a/sys/mfc/mfc_decoder/mfc_decoder.c +++ b/sys/mfc/mfc_decoder/mfc_decoder.c @@ -276,6 +276,7 @@ static int request_output_buffers(struct mfc_dec_context *ctx, int num) struct mfc_dec_context* mfc_dec_create(unsigned int codec, int num_input_buffers) { struct mfc_dec_context *ctx; + struct v4l2_capability caps; pthread_mutex_lock(&mutex); if (mfc_in_use) { @@ -301,6 +302,21 @@ struct mfc_dec_context* mfc_dec_create(unsigned int codec, int num_input_buffers free(ctx); return NULL; } + + if (ioctl (ctx->fd, VIDIOC_QUERYCAP, &caps) < 0) { + GST_ERROR ("Unable to query capabilities: %d", errno); + mfc_dec_destroy(ctx); + return NULL; + } + + if ((caps.capabilities & V4L2_CAP_STREAMING) == 0 || + (caps.capabilities & V4L2_CAP_VIDEO_OUTPUT_MPLANE) == 0 || + (caps.capabilities & V4L2_CAP_VIDEO_CAPTURE_MPLANE) == 0) { + GST_ERROR ("Required capabilities not available"); + mfc_dec_destroy(ctx); + return NULL; + } + if (mfc_dec_set_codec(ctx, codec) || request_input_buffers(ctx, num_input_buffers)) { mfc_dec_destroy(ctx);