1 // SPDX-License-Identifier: GPL-2.0-only
2 /*
3 * Copyright (c) 2020, The Linux Foundation. All rights reserved.
4 */
5 #include <linux/of.h>
6 #include "hfi_platform.h"
7 #include "core.h"
8
hfi_platform_get(enum hfi_version version)9 const struct hfi_platform *hfi_platform_get(enum hfi_version version)
10 {
11 switch (version) {
12 case HFI_VERSION_4XX:
13 return &hfi_plat_v4;
14 case HFI_VERSION_6XX:
15 return &hfi_plat_v6;
16 default:
17 break;
18 }
19
20 return NULL;
21 }
22
23 unsigned long
hfi_platform_get_codec_vpp_freq(struct venus_core * core,enum hfi_version version,u32 codec,u32 session_type)24 hfi_platform_get_codec_vpp_freq(struct venus_core *core,
25 enum hfi_version version, u32 codec,
26 u32 session_type)
27 {
28 const struct hfi_platform *plat;
29 unsigned long freq = 0;
30
31 plat = hfi_platform_get(version);
32 if (!plat)
33 return 0;
34
35 if (plat->codec_vpp_freq)
36 freq = plat->codec_vpp_freq(core, session_type, codec);
37
38 return freq;
39 }
40
41 unsigned long
hfi_platform_get_codec_vsp_freq(struct venus_core * core,enum hfi_version version,u32 codec,u32 session_type)42 hfi_platform_get_codec_vsp_freq(struct venus_core *core,
43 enum hfi_version version, u32 codec,
44 u32 session_type)
45 {
46 const struct hfi_platform *plat;
47 unsigned long freq = 0;
48
49 plat = hfi_platform_get(version);
50 if (!plat)
51 return 0;
52
53 if (plat->codec_vpp_freq)
54 freq = plat->codec_vsp_freq(core, session_type, codec);
55
56 return freq;
57 }
58
59 unsigned long
hfi_platform_get_codec_lp_freq(struct venus_core * core,enum hfi_version version,u32 codec,u32 session_type)60 hfi_platform_get_codec_lp_freq(struct venus_core *core,
61 enum hfi_version version, u32 codec,
62 u32 session_type)
63 {
64 const struct hfi_platform *plat;
65 unsigned long freq = 0;
66
67 plat = hfi_platform_get(version);
68 if (!plat)
69 return 0;
70
71 if (plat->codec_lp_freq)
72 freq = plat->codec_lp_freq(core, session_type, codec);
73
74 return freq;
75 }
76
77 int
hfi_platform_get_codecs(struct venus_core * core,u32 * enc_codecs,u32 * dec_codecs,u32 * count)78 hfi_platform_get_codecs(struct venus_core *core, u32 *enc_codecs,
79 u32 *dec_codecs, u32 *count)
80 {
81 const struct hfi_platform *plat;
82
83 plat = hfi_platform_get(core->res->hfi_version);
84 if (!plat)
85 return -EINVAL;
86
87 if (plat->codecs)
88 plat->codecs(core, enc_codecs, dec_codecs, count);
89
90 if (IS_IRIS2_1(core)) {
91 *enc_codecs &= ~HFI_VIDEO_CODEC_VP8;
92 *dec_codecs &= ~HFI_VIDEO_CODEC_VP8;
93 }
94
95 return 0;
96 }
97
98