summaryrefslogtreecommitdiffstats
path: root/drivers/media/platform/mediatek/vcodec/mtk_vcodec_dec_stateless.c
diff options
context:
space:
mode:
authorChen-Yu Tsai <wenst@chromium.org>2022-07-06 09:21:38 +0100
committerMauro Carvalho Chehab <mchehab@kernel.org>2022-07-08 18:10:29 +0100
commitcfce5b186537b0339d0872aa209a927e4a04be52 (patch)
treeb522249fa11b6853fa74d6f9ec021a0aaa96401c /drivers/media/platform/mediatek/vcodec/mtk_vcodec_dec_stateless.c
parente8d266d533b171387945f8a0bad1944a5609f63b (diff)
downloadlinux-stable-cfce5b186537b0339d0872aa209a927e4a04be52.tar.gz
linux-stable-cfce5b186537b0339d0872aa209a927e4a04be52.tar.bz2
linux-stable-cfce5b186537b0339d0872aa209a927e4a04be52.zip
media: mediatek: vcodec: decoder: Embed framesize inside mtk_video_fmt
Right now the decoder maintains two separate lists for supported pixel formats and frame sizes. Getting the supported frame sizes for the current set format is a bit convoluted, requiring a search through the separate frame size list. The frame sizes are used to clamp and align requested resolutions. Instead, the frame size structure could be embedded inside the pixel format structure. Getting one also gets the other. And since the the driver already keeps pointers to the current set format, getting the frame sizes becomes straightforward. Do just that. Move v4l2_frmsize_stepwise inside mtk_video_fmt, and get rid of mtk_codec_framesizes. Signed-off-by: Chen-Yu Tsai <wenst@chromium.org> Tested-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com> Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl> Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
Diffstat (limited to 'drivers/media/platform/mediatek/vcodec/mtk_vcodec_dec_stateless.c')
-rw-r--r--drivers/media/platform/mediatek/vcodec/mtk_vcodec_dec_stateless.c23
1 files changed, 6 insertions, 17 deletions
diff --git a/drivers/media/platform/mediatek/vcodec/mtk_vcodec_dec_stateless.c b/drivers/media/platform/mediatek/vcodec/mtk_vcodec_dec_stateless.c
index 5da9901e93a3..c45bd2599bb2 100644
--- a/drivers/media/platform/mediatek/vcodec/mtk_vcodec_dec_stateless.c
+++ b/drivers/media/platform/mediatek/vcodec/mtk_vcodec_dec_stateless.c
@@ -112,12 +112,10 @@ static const struct mtk_stateless_control mtk_stateless_controls[] = {
#define NUM_CTRLS ARRAY_SIZE(mtk_stateless_controls)
static struct mtk_video_fmt mtk_video_formats[5];
-static struct mtk_codec_framesizes mtk_vdec_framesizes[3];
static struct mtk_video_fmt default_out_format;
static struct mtk_video_fmt default_cap_format;
static unsigned int num_formats;
-static unsigned int num_framesizes;
static const struct v4l2_frmsize_stepwise stepwise_fhd = {
.min_width = MTK_VDEC_MIN_W,
@@ -348,7 +346,6 @@ static void mtk_vcodec_add_formats(unsigned int fourcc,
struct mtk_vcodec_dev *dev = ctx->dev;
const struct mtk_vcodec_dec_pdata *pdata = dev->vdec_pdata;
int count_formats = *pdata->num_formats;
- int count_framesizes = *pdata->num_framesizes;
switch (fourcc) {
case V4L2_PIX_FMT_H264_SLICE:
@@ -357,17 +354,15 @@ static void mtk_vcodec_add_formats(unsigned int fourcc,
mtk_video_formats[count_formats].fourcc = fourcc;
mtk_video_formats[count_formats].type = MTK_FMT_DEC;
mtk_video_formats[count_formats].num_planes = 1;
+ mtk_video_formats[count_formats].frmsize = stepwise_fhd;
- mtk_vdec_framesizes[count_framesizes].fourcc = fourcc;
- mtk_vdec_framesizes[count_framesizes].stepwise = stepwise_fhd;
if (!(ctx->dev->dec_capability & VCODEC_CAPABILITY_4K_DISABLED) &&
fourcc != V4L2_PIX_FMT_VP8_FRAME) {
- mtk_vdec_framesizes[count_framesizes].stepwise.max_width =
+ mtk_video_formats[count_formats].frmsize.max_width =
VCODEC_DEC_4K_CODED_WIDTH;
- mtk_vdec_framesizes[count_framesizes].stepwise.max_height =
+ mtk_video_formats[count_formats].frmsize.max_height =
VCODEC_DEC_4K_CODED_HEIGHT;
}
- num_framesizes++;
break;
case V4L2_PIX_FMT_MM21:
case V4L2_PIX_FMT_MT21C:
@@ -381,15 +376,15 @@ static void mtk_vcodec_add_formats(unsigned int fourcc,
}
num_formats++;
- mtk_v4l2_debug(3, "num_formats: %d num_frames:%d dec_capability: 0x%x",
- count_formats, count_framesizes, ctx->dev->dec_capability);
+ mtk_v4l2_debug(3, "num_formats: %d dec_capability: 0x%x",
+ count_formats, ctx->dev->dec_capability);
}
static void mtk_vcodec_get_supported_formats(struct mtk_vcodec_ctx *ctx)
{
int cap_format_count = 0, out_format_count = 0;
- if (num_formats && num_framesizes)
+ if (num_formats)
return;
if (ctx->dev->dec_capability & MTK_VDEC_FORMAT_MM21) {
@@ -468,8 +463,6 @@ const struct mtk_vcodec_dec_pdata mtk_vdec_8183_pdata = {
.num_formats = &num_formats,
.default_out_fmt = &default_out_format,
.default_cap_fmt = &default_cap_format,
- .vdec_framesizes = mtk_vdec_framesizes,
- .num_framesizes = &num_framesizes,
.uses_stateless_api = true,
.worker = mtk_vdec_worker,
.flush_decoder = mtk_vdec_flush_decoder,
@@ -488,8 +481,6 @@ const struct mtk_vcodec_dec_pdata mtk_lat_sig_core_pdata = {
.num_formats = &num_formats,
.default_out_fmt = &default_out_format,
.default_cap_fmt = &default_cap_format,
- .vdec_framesizes = mtk_vdec_framesizes,
- .num_framesizes = &num_framesizes,
.uses_stateless_api = true,
.worker = mtk_vdec_worker,
.flush_decoder = mtk_vdec_flush_decoder,
@@ -507,8 +498,6 @@ const struct mtk_vcodec_dec_pdata mtk_vdec_single_core_pdata = {
.num_formats = &num_formats,
.default_out_fmt = &default_out_format,
.default_cap_fmt = &default_cap_format,
- .vdec_framesizes = mtk_vdec_framesizes,
- .num_framesizes = &num_framesizes,
.uses_stateless_api = true,
.worker = mtk_vdec_worker,
.flush_decoder = mtk_vdec_flush_decoder,