• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2 * Copyright (C) 2017 Amlogic, Inc. All rights reserved.
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
12 * more details.
13 *
14 * You should have received a copy of the GNU General Public License along
15 * with this program; if not, write to the Free Software Foundation, Inc.,
16 * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
17 *
18 * Description:
19 */
20 #include "firmware_type.h"
21 #include "../chips/decoder_cpu_ver_info.h"
22 
23 static const struct format_name_s format_name[] = {
24 	{VIDEO_DEC_MPEG12,		"mpeg12"},
25 	{VIDEO_DEC_MPEG12_MULTI,	"mpeg12_multi"},
26 	{VIDEO_DEC_MPEG4_3,		"mpeg4_3"},
27 	{VIDEO_DEC_MPEG4_4,		"mpeg4_4"},
28 	{VIDEO_DEC_MPEG4_4_MULTI,	"mpeg4_4_multi"},
29 	{VIDEO_DEC_MPEG4_5,		"xvid"},
30 	{VIDEO_DEC_MPEG4_5_MULTI,	"xvid_multi"},
31 	{VIDEO_DEC_H263,		"h263"},
32 	{VIDEO_DEC_H263_MULTI,		"h263_multi"},
33 	{VIDEO_DEC_MJPEG,		"mjpeg"},
34 	{VIDEO_DEC_MJPEG_MULTI,		"mjpeg_multi"},
35 	{VIDEO_DEC_REAL_V8,		"real_v8"},
36 	{VIDEO_DEC_REAL_V9,		"real_v9"},
37 	{VIDEO_DEC_VC1,			"vc1"},
38 	{VIDEO_DEC_VC1_G12A,		"vc1_g12a"},
39 	{VIDEO_DEC_AVS,			"avs"},
40 	{VIDEO_DEC_AVS_GXM,		"avs_gxm"},
41 	{VIDEO_DEC_AVS_NOCABAC,		"avs_no_cabac"},
42 	{VIDEO_DEC_AVS_MULTI,		"avs_multi"},
43 	{VIDEO_DEC_H264,		"h264"},
44 	{VIDEO_DEC_H264_MVC,		"h264_mvc"},
45 	{VIDEO_DEC_H264_MVC_GXM,	"h264_mvc_gxm"},
46 	{VIDEO_DEC_H264_MULTI,		"h264_multi"},
47 	{VIDEO_DEC_H264_MULTI_MMU,	"h264_multi_mmu"},
48 	{VIDEO_DEC_H264_MULTI_GXM,	"h264_multi_gxm"},
49 	{VIDEO_DEC_HEVC,		"hevc"},
50 	{VIDEO_DEC_HEVC_MMU,		"hevc_mmu"},
51 	{VIDEO_DEC_HEVC_MMU_SWAP,	"hevc_mmu_swap"},
52 	{VIDEO_DEC_HEVC_G12A,		"hevc_g12a"},
53 	{VIDEO_DEC_VP9,			"vp9"},
54 	{VIDEO_DEC_VP9_MMU,		"vp9_mmu"},
55 	{VIDEO_DEC_VP9_G12A,		"vp9_g12a"},
56 	{VIDEO_DEC_AVS2,		"avs2"},
57 	{VIDEO_DEC_AVS2_MMU,		"avs2_mmu"},
58 	{VIDEO_DEC_AV1_MMU,		"av1_mmu"},
59 	{VIDEO_ENC_H264,		"h264_enc"},
60 	{VIDEO_ENC_JPEG,		"jpeg_enc"},
61 	{FIRMWARE_MAX,			"unknown"},
62 };
63 
64 static const struct cpu_type_s cpu_type[] = {
65 	{AM_MESON_CPU_MAJOR_ID_GXL,	"gxl"},
66 	{AM_MESON_CPU_MAJOR_ID_GXM,	"gxm"},
67 	{AM_MESON_CPU_MAJOR_ID_TXL,	"txl"},
68 	{AM_MESON_CPU_MAJOR_ID_TXLX,	"txlx"},
69 	{AM_MESON_CPU_MAJOR_ID_AXG,	"axg"},
70 	{AM_MESON_CPU_MAJOR_ID_GXLX,	"gxlx"},
71 	{AM_MESON_CPU_MAJOR_ID_TXHD,	"txhd"},
72 	{AM_MESON_CPU_MAJOR_ID_G12A,	"g12a"},
73 	{AM_MESON_CPU_MAJOR_ID_G12B,	"g12b"},
74 	{AM_MESON_CPU_MAJOR_ID_GXLX2,	"gxlx2"},
75 	{AM_MESON_CPU_MAJOR_ID_SM1,	"sm1"},
76 	{AM_MESON_CPU_MAJOR_ID_TL1,	"tl1"},
77 	{AM_MESON_CPU_MAJOR_ID_TM2,	"tm2"},
78 };
79 
get_fw_format_name(unsigned int format)80 const char *get_fw_format_name(unsigned int format)
81 {
82 	const char *name = "unknown";
83 	int i, size = ARRAY_SIZE(format_name);
84 
85 	for (i = 0; i < size; i++) {
86 		if (format == format_name[i].format)
87 			name = format_name[i].name;
88 	}
89 
90 	return name;
91 }
92 EXPORT_SYMBOL(get_fw_format_name);
93 
get_fw_format(const char * name)94 unsigned int get_fw_format(const char *name)
95 {
96 	unsigned int format = FIRMWARE_MAX;
97 	int i, size = ARRAY_SIZE(format_name);
98 
99 	for (i = 0; i < size; i++) {
100 		if (!strcmp(name, format_name[i].name))
101 			format = format_name[i].format;
102 	}
103 
104 	return format;
105 }
106 EXPORT_SYMBOL(get_fw_format);
107 
fw_get_cpu(const char * name)108 int fw_get_cpu(const char *name)
109 {
110 	int type = 0;
111 	int i, size = ARRAY_SIZE(cpu_type);
112 
113 	for (i = 0; i < size; i++) {
114 		if (!strcmp(name, cpu_type[i].name))
115 			type = cpu_type[i].type;
116 	}
117 
118 	return type;
119 }
120 EXPORT_SYMBOL(fw_get_cpu);
121 
122