diff options
author | Jernej Skrabec <jernej.skrabec@gmail.com> | 2022-11-02 21:08:03 +0300 |
---|---|---|
committer | Hans Verkuil <hverkuil-cisco@xs4all.nl> | 2022-11-04 18:56:33 +0300 |
commit | e7efb377ea50adf4a3583dd048453cca5f803775 (patch) | |
tree | 9cf53ecde3bb72ed6ca1f79f21b08cd3da74cb2d /drivers/staging/media/sunxi/cedrus/cedrus_video.c | |
parent | bc603309688b77c848c00b9fa19a4fe0b9c677b6 (diff) | |
download | linux-e7efb377ea50adf4a3583dd048453cca5f803775.tar.xz |
media: cedrus: Add helper for checking capabilities
There is several different Cedrus cores with varying capabilities, so
some operations like listing formats depends on checks if feature is
supported or not.
Currently check for capabilities is only in format handling functions,
but it will be used also elsewhere later. Let's convert this check to
helper and while at it, also simplify it. There is no need to check if
capability mask is zero, condition will still work properly.
No functional changes intended.
Signed-off-by: Jernej Skrabec <jernej.skrabec@gmail.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Diffstat (limited to 'drivers/staging/media/sunxi/cedrus/cedrus_video.c')
-rw-r--r-- | drivers/staging/media/sunxi/cedrus/cedrus_video.c | 24 |
1 files changed, 8 insertions, 16 deletions
diff --git a/drivers/staging/media/sunxi/cedrus/cedrus_video.c b/drivers/staging/media/sunxi/cedrus/cedrus_video.c index ef053986067f..77c537e7a2de 100644 --- a/drivers/staging/media/sunxi/cedrus/cedrus_video.c +++ b/drivers/staging/media/sunxi/cedrus/cedrus_video.c @@ -73,8 +73,8 @@ static inline struct cedrus_ctx *cedrus_file2ctx(struct file *file) return container_of(file->private_data, struct cedrus_ctx, fh); } -static struct cedrus_format *cedrus_find_format(u32 pixelformat, u32 directions, - unsigned int capabilities) +static struct cedrus_format *cedrus_find_format(struct cedrus_ctx *ctx, + u32 pixelformat, u32 directions) { struct cedrus_format *first_valid_fmt = NULL; struct cedrus_format *fmt; @@ -83,7 +83,7 @@ static struct cedrus_format *cedrus_find_format(u32 pixelformat, u32 directions, for (i = 0; i < CEDRUS_FORMATS_COUNT; i++) { fmt = &cedrus_formats[i]; - if ((fmt->capabilities & capabilities) != fmt->capabilities || + if (!cedrus_is_capable(ctx, fmt->capabilities) || !(fmt->directions & directions)) continue; @@ -177,19 +177,13 @@ static int cedrus_enum_fmt(struct file *file, struct v4l2_fmtdesc *f, u32 direction) { struct cedrus_ctx *ctx = cedrus_file2ctx(file); - struct cedrus_dev *dev = ctx->dev; - unsigned int capabilities = dev->capabilities; - struct cedrus_format *fmt; unsigned int i, index; /* Index among formats that match the requested direction. */ index = 0; for (i = 0; i < CEDRUS_FORMATS_COUNT; i++) { - fmt = &cedrus_formats[i]; - - if (fmt->capabilities && (fmt->capabilities & capabilities) != - fmt->capabilities) + if (!cedrus_is_capable(ctx, cedrus_formats[i].capabilities)) continue; if (!(cedrus_formats[i].directions & direction)) @@ -244,10 +238,9 @@ static int cedrus_g_fmt_vid_out(struct file *file, void *priv, static int cedrus_try_fmt_vid_cap_p(struct cedrus_ctx *ctx, struct v4l2_pix_format *pix_fmt) { - struct cedrus_dev *dev = ctx->dev; struct cedrus_format *fmt = - cedrus_find_format(pix_fmt->pixelformat, CEDRUS_DECODE_DST, - dev->capabilities); + cedrus_find_format(ctx, pix_fmt->pixelformat, + CEDRUS_DECODE_DST); if (!fmt) return -EINVAL; @@ -269,10 +262,9 @@ static int cedrus_try_fmt_vid_cap(struct file *file, void *priv, static int cedrus_try_fmt_vid_out_p(struct cedrus_ctx *ctx, struct v4l2_pix_format *pix_fmt) { - struct cedrus_dev *dev = ctx->dev; struct cedrus_format *fmt = - cedrus_find_format(pix_fmt->pixelformat, CEDRUS_DECODE_SRC, - dev->capabilities); + cedrus_find_format(ctx, pix_fmt->pixelformat, + CEDRUS_DECODE_SRC); if (!fmt) return -EINVAL; |