]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
media: venus: helpers: Add helper to check supported pixel formats
authorStanimir Varbanov <stanimir.varbanov@linaro.org>
Thu, 3 Mar 2022 15:06:32 +0000 (15:06 +0000)
committerMauro Carvalho Chehab <mchehab@kernel.org>
Sun, 24 Apr 2022 07:33:10 +0000 (08:33 +0100)
Add a helper to check supported pixel format per codec and session
type.

Signed-off-by: Stanimir Varbanov <stanimir.varbanov@linaro.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
drivers/media/platform/qcom/venus/helpers.c
drivers/media/platform/qcom/venus/helpers.h

index fa01edd54c038b5ae295736ec3fb3e2d0f5270db..b8ceda0aa3220c3bdbc25f4f0a7d8a47d2e72b96 100644 (file)
@@ -1813,6 +1813,29 @@ int venus_helper_get_out_fmts(struct venus_inst *inst, u32 v4l2_fmt,
 }
 EXPORT_SYMBOL_GPL(venus_helper_get_out_fmts);
 
+bool venus_helper_check_format(struct venus_inst *inst, u32 v4l2_pixfmt)
+{
+       struct venus_core *core = inst->core;
+       u32 fmt = to_hfi_raw_fmt(v4l2_pixfmt);
+       struct hfi_plat_caps *caps;
+       u32 buftype;
+
+       if (!fmt)
+               return false;
+
+       caps = venus_caps_by_codec(core, inst->hfi_codec, inst->session_type);
+       if (!caps)
+               return false;
+
+       if (inst->session_type == VIDC_SESSION_TYPE_DEC)
+               buftype = HFI_BUFFER_OUTPUT2;
+       else
+               buftype = HFI_BUFFER_OUTPUT;
+
+       return find_fmt_from_caps(caps, buftype, fmt);
+}
+EXPORT_SYMBOL_GPL(venus_helper_check_format);
+
 int venus_helper_set_stride(struct venus_inst *inst,
                            unsigned int width, unsigned int height)
 {
index 32619c3e8c976740e9cd3e08f66836be19161fec..358e4f39c9c038b46c10707cc5cfcf9cc7ca7db8 100644 (file)
@@ -55,6 +55,7 @@ void venus_helper_init_instance(struct venus_inst *inst);
 int venus_helper_session_init(struct venus_inst *inst);
 int venus_helper_get_out_fmts(struct venus_inst *inst, u32 fmt, u32 *out_fmt,
                              u32 *out2_fmt, bool ubwc);
+bool venus_helper_check_format(struct venus_inst *inst, u32 v4l2_pixfmt);
 int venus_helper_alloc_dpb_bufs(struct venus_inst *inst);
 int venus_helper_free_dpb_bufs(struct venus_inst *inst);
 int venus_helper_intbufs_alloc(struct venus_inst *inst);