media: venus: add helper to check supported codecs
authorStanimir Varbanov <stanimir.varbanov@linaro.org>
Fri, 18 Aug 2017 14:16:04 +0000 (10:16 -0400)
committerMauro Carvalho Chehab <mchehab@s-opensource.com>
Sat, 26 Aug 2017 12:45:03 +0000 (08:45 -0400)
Adds a helper function to runtime check supported encoder and
decoder codecs depending on venus version and platform.

Signed-off-by: Stanimir Varbanov <stanimir.varbanov@linaro.org>
Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
drivers/media/platform/qcom/venus/helpers.c
drivers/media/platform/qcom/venus/helpers.h

index 5f4434c0a8f189c8bda5ca16fc37b04f5bead04a..b52410deeb4c31d64acbd4bbb1289b5648494fe7 100644 (file)
@@ -34,6 +34,55 @@ struct intbuf {
        unsigned long attrs;
 };
 
+bool venus_helper_check_codec(struct venus_inst *inst, u32 v4l2_pixfmt)
+{
+       struct venus_core *core = inst->core;
+       u32 session_type = inst->session_type;
+       u32 codec;
+
+       switch (v4l2_pixfmt) {
+       case V4L2_PIX_FMT_H264:
+               codec = HFI_VIDEO_CODEC_H264;
+               break;
+       case V4L2_PIX_FMT_H263:
+               codec = HFI_VIDEO_CODEC_H263;
+               break;
+       case V4L2_PIX_FMT_MPEG1:
+               codec = HFI_VIDEO_CODEC_MPEG1;
+               break;
+       case V4L2_PIX_FMT_MPEG2:
+               codec = HFI_VIDEO_CODEC_MPEG2;
+               break;
+       case V4L2_PIX_FMT_MPEG4:
+               codec = HFI_VIDEO_CODEC_MPEG4;
+               break;
+       case V4L2_PIX_FMT_VC1_ANNEX_G:
+       case V4L2_PIX_FMT_VC1_ANNEX_L:
+               codec = HFI_VIDEO_CODEC_VC1;
+               break;
+       case V4L2_PIX_FMT_VP8:
+               codec = HFI_VIDEO_CODEC_VP8;
+               break;
+       case V4L2_PIX_FMT_VP9:
+               codec = HFI_VIDEO_CODEC_VP9;
+               break;
+       case V4L2_PIX_FMT_XVID:
+               codec = HFI_VIDEO_CODEC_DIVX;
+               break;
+       default:
+               return false;
+       }
+
+       if (session_type == VIDC_SESSION_TYPE_ENC && core->enc_codecs & codec)
+               return true;
+
+       if (session_type == VIDC_SESSION_TYPE_DEC && core->dec_codecs & codec)
+               return true;
+
+       return false;
+}
+EXPORT_SYMBOL_GPL(venus_helper_check_codec);
+
 static int intbufs_set_buffer(struct venus_inst *inst, u32 type)
 {
        struct venus_core *core = inst->core;
index 6a061b417a9367883d005a404928e21778f668d0..971392be5df574df0afd63175dfb3cb35ff22624 100644 (file)
@@ -19,6 +19,7 @@
 
 struct venus_inst;
 
+bool venus_helper_check_codec(struct venus_inst *inst, u32 v4l2_pixfmt);
 struct vb2_v4l2_buffer *venus_helper_find_buf(struct venus_inst *inst,
                                              unsigned int type, u32 idx);
 void venus_helper_buffers_done(struct venus_inst *inst,