1 // SPDX-License-Identifier: GPL-2.0-only
2 /*
3  * Copyright (c) 2020, The Linux Foundation. All rights reserved.
4  */
5 #include "hfi_platform.h"
6 
7 const struct hfi_platform *hfi_platform_get(enum hfi_version version)
8 {
9 	switch (version) {
10 	case HFI_VERSION_4XX:
11 		return &hfi_plat_v4;
12 	case HFI_VERSION_6XX:
13 		return &hfi_plat_v6;
14 	default:
15 		break;
16 	}
17 
18 	return NULL;
19 }
20 
21 unsigned long
22 hfi_platform_get_codec_vpp_freq(enum hfi_version version, u32 codec, u32 session_type)
23 {
24 	const struct hfi_platform *plat;
25 	unsigned long freq = 0;
26 
27 	plat = hfi_platform_get(version);
28 	if (!plat)
29 		return 0;
30 
31 	if (plat->codec_vpp_freq)
32 		freq = plat->codec_vpp_freq(session_type, codec);
33 
34 	return freq;
35 }
36 
37 unsigned long
38 hfi_platform_get_codec_vsp_freq(enum hfi_version version, u32 codec, u32 session_type)
39 {
40 	const struct hfi_platform *plat;
41 	unsigned long freq = 0;
42 
43 	plat = hfi_platform_get(version);
44 	if (!plat)
45 		return 0;
46 
47 	if (plat->codec_vpp_freq)
48 		freq = plat->codec_vsp_freq(session_type, codec);
49 
50 	return freq;
51 }
52 
53 u8 hfi_platform_num_vpp_pipes(enum hfi_version version)
54 {
55 	const struct hfi_platform *plat;
56 
57 	plat = hfi_platform_get(version);
58 	if (!plat)
59 		return 0;
60 
61 	if (plat->num_vpp_pipes)
62 		return plat->num_vpp_pipes();
63 
64 	return 0;
65 }
66