1 /* SPDX-License-Identifier: GPL-2.0-only */
2 /*
3  * Copyright (c) 2020, The Linux Foundation. All rights reserved.
4  */
5 
6 #ifndef __HFI_PLATFORM_H__
7 #define __HFI_PLATFORM_H__
8 
9 #include <linux/types.h>
10 #include <linux/videodev2.h>
11 
12 #include "hfi.h"
13 #include "hfi_plat_bufs.h"
14 #include "hfi_helper.h"
15 
16 #define MAX_PLANES		4
17 #define MAX_FMT_ENTRIES		32
18 #define MAX_CAP_ENTRIES		32
19 #define MAX_ALLOC_MODE_ENTRIES	16
20 #define MAX_CODEC_NUM		32
21 #define MAX_SESSIONS		16
22 
23 struct raw_formats {
24 	u32 buftype;
25 	u32 fmt;
26 };
27 
28 struct hfi_plat_caps {
29 	u32 codec;
30 	u32 domain;
31 	bool cap_bufs_mode_dynamic;
32 	unsigned int num_caps;
33 	struct hfi_capability caps[MAX_CAP_ENTRIES];
34 	unsigned int num_pl;
35 	struct hfi_profile_level pl[HFI_MAX_PROFILE_COUNT];
36 	unsigned int num_fmts;
37 	struct raw_formats fmts[MAX_FMT_ENTRIES];
38 	bool valid;	/* used only for Venus v1xx */
39 };
40 
41 struct hfi_platform_codec_freq_data {
42 	u32 pixfmt;
43 	u32 session_type;
44 	unsigned long vpp_freq;
45 	unsigned long vsp_freq;
46 };
47 
48 struct hfi_platform {
49 	unsigned long (*codec_vpp_freq)(u32 session_type, u32 codec);
50 	unsigned long (*codec_vsp_freq)(u32 session_type, u32 codec);
51 	void (*codecs)(u32 *enc_codecs, u32 *dec_codecs, u32 *count);
52 	const struct hfi_plat_caps *(*capabilities)(unsigned int *entries);
53 	u8 (*num_vpp_pipes)(void);
54 	int (*bufreq)(struct hfi_plat_buffers_params *params, u32 session_type,
55 		      u32 buftype, struct hfi_buffer_requirements *bufreq);
56 };
57 
58 extern const struct hfi_platform hfi_plat_v4;
59 extern const struct hfi_platform hfi_plat_v6;
60 
61 const struct hfi_platform *hfi_platform_get(enum hfi_version version);
62 unsigned long hfi_platform_get_codec_vpp_freq(enum hfi_version version, u32 codec,
63 					      u32 session_type);
64 unsigned long hfi_platform_get_codec_vsp_freq(enum hfi_version version, u32 codec,
65 					      u32 session_type);
66 u8 hfi_platform_num_vpp_pipes(enum hfi_version version);
67 #endif
68