aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/platform/coda/coda-mpeg2.c
blob: 73e50dabce19483c4b6ca213c89005de81646f45 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
// SPDX-License-Identifier: GPL-2.0-or-later
/*
 * Coda multi-standard codec IP - MPEG-2 helper functions
 *
 * Copyright (C) 2019 Pengutronix, Philipp Zabel
 */

#include <linux/kernel.h>
#include <linux/videodev2.h>
#include "coda.h"

int coda_mpeg2_profile(int profile_idc)
{
	switch (profile_idc) {
	case 5:
		return V4L2_MPEG_VIDEO_MPEG2_PROFILE_SIMPLE;
	case 4:
		return V4L2_MPEG_VIDEO_MPEG2_PROFILE_MAIN;
	case 3:
		return V4L2_MPEG_VIDEO_MPEG2_PROFILE_SNR_SCALABLE;
	case 2:
		return V4L2_MPEG_VIDEO_MPEG2_PROFILE_SPATIALLY_SCALABLE;
	case 1:
		return V4L2_MPEG_VIDEO_MPEG2_PROFILE_HIGH;
	default:
		return -EINVAL;
	}
}

int coda_mpeg2_level(int level_idc)
{
	switch (level_idc) {
	case 10:
		return V4L2_MPEG_VIDEO_MPEG2_LEVEL_LOW;
	case 8:
		return V4L2_MPEG_VIDEO_MPEG2_LEVEL_MAIN;
	case 6:
		return V4L2_MPEG_VIDEO_MPEG2_LEVEL_HIGH_1440;
	case 4:
		return V4L2_MPEG_VIDEO_MPEG2_LEVEL_HIGH;
	default:
		return -EINVAL;
	}
}