summaryrefslogtreecommitdiff
path: root/drivers/common/chips/chips.c (plain)
blob: 63d55ba9fe9977a1b466833c8e3ab80d3db3775f
1/*
2 * drivers/amlogic/media/common/arch/chips/chips.c
3 *
4 * Copyright (C) 2016 Amlogic, Inc. All rights reserved.
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
14 * more details.
15 *
16 */
17
18#include <linux/kernel.h>
19#include <linux/module.h>
20#include <linux/types.h>
21#include <linux/fs.h>
22#include <linux/init.h>
23#include <linux/device.h>
24#include <linux/vmalloc.h>
25#include <linux/mm.h>
26
27#include <linux/amlogic/media/utils/vformat.h>
28#include <linux/amlogic/cpu_version.h>
29#include "../../stream_input/amports/amports_priv.h"
30#include "../../frame_provider/decoder/utils/vdec.h"
31#include "chips.h"
32#include <linux/amlogic/media/utils/log.h>
33#include <linux/amlogic/media/utils/vdec_reg.h>
34#include "decoder_cpu_ver_info.h"
35
36#define VIDEO_FIRMWARE_FATHER_NAME "video"
37
38/*
39 *#define MESON_CPU_MAJOR_ID_M6 0x16
40 *#define MESON_CPU_MAJOR_ID_M6TV 0x17
41 *#define MESON_CPU_MAJOR_ID_M6TVL 0x18
42 *#define MESON_CPU_MAJOR_ID_M8 0x19
43 *#define MESON_CPU_MAJOR_ID_MTVD 0x1A
44 *#define MESON_CPU_MAJOR_ID_M8B 0x1B
45 *#define MESON_CPU_MAJOR_ID_MG9TV 0x1C
46 *#define MESON_CPU_MAJOR_ID_M8M2 0x1D
47 *#define MESON_CPU_MAJOR_ID_GXBB 0x1F
48 *#define MESON_CPU_MAJOR_ID_GXTVBB 0x20
49 *#define MESON_CPU_MAJOR_ID_GXL 0x21
50 *#define MESON_CPU_MAJOR_ID_GXM 0x22
51 *#define MESON_CPU_MAJOR_ID_TXL 0x23
52 */
53struct type_name {
54
55 int type;
56
57 const char *name;
58};
59static const struct type_name cpu_type_name[] = {
60 {AM_MESON_CPU_MAJOR_ID_M6, "m6"},
61 {AM_MESON_CPU_MAJOR_ID_M6TV, "m6tv"},
62 {AM_MESON_CPU_MAJOR_ID_M6TVL, "m6tvl"},
63 {AM_MESON_CPU_MAJOR_ID_M8, "m8"},
64 {AM_MESON_CPU_MAJOR_ID_MTVD, "mtvd"},
65 {AM_MESON_CPU_MAJOR_ID_M8B, "m8b"},
66 {AM_MESON_CPU_MAJOR_ID_MG9TV, "mg9tv"},
67 {AM_MESON_CPU_MAJOR_ID_M8M2, "m8"},
68 {AM_MESON_CPU_MAJOR_ID_GXBB, "gxbb"},
69 {AM_MESON_CPU_MAJOR_ID_GXTVBB, "gxtvbb"},
70 {AM_MESON_CPU_MAJOR_ID_GXL, "gxl"},
71 {AM_MESON_CPU_MAJOR_ID_GXM, "gxm"},
72 {AM_MESON_CPU_MAJOR_ID_TXL, "txl"},
73 {AM_MESON_CPU_MAJOR_ID_TXLX, "txlx"},
74 {AM_MESON_CPU_MAJOR_ID_G12A, "g12a"},
75 {AM_MESON_CPU_MAJOR_ID_G12B, "g12b"},
76 {AM_MESON_CPU_MAJOR_ID_SM1, "sm1"},
77 {AM_MESON_CPU_MAJOR_ID_TL1, "tl1"},
78 {AM_MESON_CPU_MAJOR_ID_TM2, "tm2"},
79 {0, NULL},
80};
81
82static const char *get_type_name(const struct type_name *typename, int size,
83 int type)
84{
85
86 const char *name = "unknown";
87
88 int i;
89
90 for (i = 0; i < size; i++) {
91
92 if (type == typename[i].type)
93
94 name = typename[i].name;
95
96 }
97
98 return name;
99}
100
101const char *get_cpu_type_name(void)
102{
103
104 return get_type_name(cpu_type_name,
105 sizeof(cpu_type_name) / sizeof(struct type_name),
106 get_cpu_major_id());
107}
108EXPORT_SYMBOL(get_cpu_type_name);
109
110/*
111 *enum vformat_e {
112 * VFORMAT_MPEG12 = 0,
113 * VFORMAT_MPEG4,
114 * VFORMAT_H264,
115 * VFORMAT_MJPEG,
116 * VFORMAT_REAL,
117 * VFORMAT_JPEG,
118 * VFORMAT_VC1,
119 * VFORMAT_AVS,
120 * VFORMAT_YUV,
121 * VFORMAT_H264MVC,
122 * VFORMAT_H264_4K2K,
123 * VFORMAT_HEVC,
124 * VFORMAT_H264_ENC,
125 * VFORMAT_JPEG_ENC,
126 * VFORMAT_VP9,
127* VFORMAT_AVS2,
128 * VFORMAT_MAX
129 *};
130 */
131static const struct type_name vformat_type_name[] = {
132 {VFORMAT_MPEG12, "mpeg12"},
133 {VFORMAT_MPEG4, "mpeg4"},
134 {VFORMAT_H264, "h264"},
135 {VFORMAT_MJPEG, "mjpeg"},
136 {VFORMAT_REAL, "real"},
137 {VFORMAT_JPEG, "jpeg"},
138 {VFORMAT_VC1, "vc1"},
139 {VFORMAT_AVS, "avs"},
140 {VFORMAT_YUV, "yuv"},
141 {VFORMAT_H264MVC, "h264mvc"},
142 {VFORMAT_H264_4K2K, "h264_4k"},
143 {VFORMAT_HEVC, "hevc"},
144 {VFORMAT_H264_ENC, "h264_enc"},
145 {VFORMAT_JPEG_ENC, "jpeg_enc"},
146 {VFORMAT_VP9, "vp9"},
147 {VFORMAT_AVS2, "avs2"},
148 {VFORMAT_YUV, "yuv"},
149 {0, NULL},
150};
151
152const char *get_video_format_name(enum vformat_e type)
153{
154
155 return get_type_name(vformat_type_name,
156 sizeof(vformat_type_name) / sizeof(struct type_name), type);
157}
158EXPORT_SYMBOL(get_video_format_name);
159
160static struct chip_vdec_info_s current_chip_info;
161
162struct chip_vdec_info_s *get_current_vdec_chip(void)
163{
164
165 return &current_chip_info;
166}
167EXPORT_SYMBOL(get_current_vdec_chip);
168
169bool check_efuse_chip(int vformat)
170{
171 unsigned int status, i = 0;
172 int type[] = {15, 14, 11, 2}; /* avs2, vp9, h265, h264 */
173
174 status = (READ_EFUSE_REG(EFUSE_LIC2) >> 8 & 0xf);
175 if (!status)
176 return false;
177
178 do {
179 if ((status & 1) && (type[i] == vformat))
180 return true;
181 i++;
182 } while (status >>= 1);
183
184 return false;
185}
186EXPORT_SYMBOL(check_efuse_chip);
187
188