summaryrefslogtreecommitdiff
path: root/drivers/common/firmware/firmware_type.c (plain)
blob: e781a51ac2d0b90c880dc43a6ea5f206e76cdf96
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
23static 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_ENC_H264, "h264_enc"},
59 {VIDEO_ENC_JPEG, "jpeg_enc"},
60 {FIRMWARE_MAX, "unknown"},
61};
62
63static const struct cpu_type_s cpu_type[] = {
64 {AM_MESON_CPU_MAJOR_ID_GXL, "gxl"},
65 {AM_MESON_CPU_MAJOR_ID_GXM, "gxm"},
66 {AM_MESON_CPU_MAJOR_ID_TXL, "txl"},
67 {AM_MESON_CPU_MAJOR_ID_TXLX, "txlx"},
68 {AM_MESON_CPU_MAJOR_ID_AXG, "axg"},
69 {AM_MESON_CPU_MAJOR_ID_GXLX, "gxlx"},
70 {AM_MESON_CPU_MAJOR_ID_TXHD, "txhd"},
71 {AM_MESON_CPU_MAJOR_ID_G12A, "g12a"},
72 {AM_MESON_CPU_MAJOR_ID_G12B, "g12b"},
73 {AM_MESON_CPU_MAJOR_ID_GXLX2, "gxlx2"},
74 {AM_MESON_CPU_MAJOR_ID_SM1, "sm1"},
75 {AM_MESON_CPU_MAJOR_ID_TL1, "tl1"},
76 {AM_MESON_CPU_MAJOR_ID_TM2, "tm2"},
77};
78
79const char *get_fw_format_name(unsigned int format)
80{
81 const char *name = "unknown";
82 int i, size = ARRAY_SIZE(format_name);
83
84 for (i = 0; i < size; i++) {
85 if (format == format_name[i].format)
86 name = format_name[i].name;
87 }
88
89 return name;
90}
91EXPORT_SYMBOL(get_fw_format_name);
92
93unsigned int get_fw_format(const char *name)
94{
95 unsigned int format = FIRMWARE_MAX;
96 int i, size = ARRAY_SIZE(format_name);
97
98 for (i = 0; i < size; i++) {
99 if (!strcmp(name, format_name[i].name))
100 format = format_name[i].format;
101 }
102
103 return format;
104}
105EXPORT_SYMBOL(get_fw_format);
106
107int fw_get_cpu(const char *name)
108{
109 int type = 0;
110 int i, size = ARRAY_SIZE(cpu_type);
111
112 for (i = 0; i < size; i++) {
113 if (!strcmp(name, cpu_type[i].name))
114 type = cpu_type[i].type;
115 }
116
117 return type;
118}
119EXPORT_SYMBOL(fw_get_cpu);
120
121