mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2026-05-14 10:02:33 -04:00
media: verisilicon: Use V4L2_FMTDESC_FLAG_ENUM_ALL flag
By adding support for the V4L2_FMTDESC_FLAG_ENUM_ALL flag into the driver we allow userspace applications to discover all possible pixel formats of the hardware block. This way userspace can decide which decoder to use given the supported pixel formats. Signed-off-by: Benjamin Gaignard <benjamin.gaignard@collabora.com> Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
This commit is contained in:
committed by
Hans Verkuil
parent
1faaae7760
commit
bcd4f091cf
@@ -201,7 +201,15 @@ static int vidioc_enum_fmt(struct file *file, void *priv,
|
||||
struct hantro_ctx *ctx = fh_to_ctx(priv);
|
||||
const struct hantro_fmt *fmt, *formats;
|
||||
unsigned int num_fmts, i, j = 0;
|
||||
bool skip_mode_none;
|
||||
bool skip_mode_none, enum_all_formats;
|
||||
u32 index = f->index & ~V4L2_FMTDESC_FLAG_ENUM_ALL;
|
||||
|
||||
/*
|
||||
* If the V4L2_FMTDESC_FLAG_ENUM_ALL flag is set, we want to enumerate all
|
||||
* hardware supported pixel formats
|
||||
*/
|
||||
enum_all_formats = !!(f->index & V4L2_FMTDESC_FLAG_ENUM_ALL);
|
||||
f->index = index;
|
||||
|
||||
/*
|
||||
* When dealing with an encoder:
|
||||
@@ -222,9 +230,9 @@ static int vidioc_enum_fmt(struct file *file, void *priv,
|
||||
|
||||
if (skip_mode_none == mode_none)
|
||||
continue;
|
||||
if (!hantro_check_depth_match(fmt, ctx->bit_depth))
|
||||
if (!hantro_check_depth_match(fmt, ctx->bit_depth) && !enum_all_formats)
|
||||
continue;
|
||||
if (j == f->index) {
|
||||
if (j == index) {
|
||||
f->pixelformat = fmt->fourcc;
|
||||
return 0;
|
||||
}
|
||||
@@ -242,9 +250,9 @@ static int vidioc_enum_fmt(struct file *file, void *priv,
|
||||
for (i = 0; i < num_fmts; i++) {
|
||||
fmt = &formats[i];
|
||||
|
||||
if (!hantro_check_depth_match(fmt, ctx->bit_depth))
|
||||
if (!hantro_check_depth_match(fmt, ctx->bit_depth) && !enum_all_formats)
|
||||
continue;
|
||||
if (j == f->index) {
|
||||
if (j == index) {
|
||||
f->pixelformat = fmt->fourcc;
|
||||
return 0;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user