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
23struct raw_formats {
24	u32 buftype;
25	u32 fmt;
26};
27
28struct 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
41struct hfi_platform_codec_freq_data {
42	u32 pixfmt;
43	u32 session_type;
44	unsigned long vpp_freq;
45	unsigned long vsp_freq;
46	unsigned long low_power_freq;
47};
48
49struct hfi_platform {
50	unsigned long (*codec_vpp_freq)(u32 session_type, u32 codec);
51	unsigned long (*codec_vsp_freq)(u32 session_type, u32 codec);
52	unsigned long (*codec_lp_freq)(u32 session_type, u32 codec);
53	void (*codecs)(u32 *enc_codecs, u32 *dec_codecs, u32 *count);
54	const struct hfi_plat_caps *(*capabilities)(unsigned int *entries);
55	int (*bufreq)(struct hfi_plat_buffers_params *params, u32 session_type,
56		      u32 buftype, struct hfi_buffer_requirements *bufreq);
57};
58
59extern const struct hfi_platform hfi_plat_v4;
60extern const struct hfi_platform hfi_plat_v6;
61
62const struct hfi_platform *hfi_platform_get(enum hfi_version version);
63unsigned long hfi_platform_get_codec_vpp_freq(enum hfi_version version, u32 codec,
64					      u32 session_type);
65unsigned long hfi_platform_get_codec_vsp_freq(enum hfi_version version, u32 codec,
66					      u32 session_type);
67unsigned long hfi_platform_get_codec_lp_freq(enum hfi_version version, u32 codec,
68					     u32 session_type);
69int hfi_platform_get_codecs(struct venus_core *core, u32 *enc_codecs, u32 *dec_codecs,
70			    u32 *count);
71#endif
72