summaryrefslogtreecommitdiff
path: root/drivers/media/platform/starfive/stf_csi.h
blob: 0fa786b6716299a0ff2d470e7a0a86b5352e719a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
// SPDX-License-Identifier: GPL-2.0
/*
 * Copyright (C) 2021 StarFive Technology Co., Ltd.
 */
#ifndef STF_CSI_H
#define STF_CSI_H

#include <media/v4l2-subdev.h>
#include <media/v4l2-device.h>
#include <media/media-entity.h>
#include <video/stf-vin.h>

#define STF_CSI_PAD_SINK     0
#define STF_CSI_PAD_SRC      1
#define STF_CSI_PADS_NUM     2

struct csi_format {
	u32 code;
	u8 bpp;
};

struct stf_csi_dev;

struct csi_hw_ops {
	int (*csi_clk_enable)(struct stf_csi_dev *csi_dev);
	int (*csi_clk_disable)(struct stf_csi_dev *csi_dev);
	int (*csi_config_set)(struct stf_csi_dev *csi_dev);
	int (*csi_set_format)(struct stf_csi_dev *csi_dev,
			u32 vsize, u8 bpp, int is_raw10);
	int (*csi_stream_set)(struct stf_csi_dev *csi_dev, int on);
};

struct stf_csi_dev {
	struct stfcamss *stfcamss;
	u8 id;
	u8 csiphy_id;
	enum sensor_type s_type;
	struct v4l2_subdev subdev;
	struct media_pad pads[STF_CSI_PADS_NUM];
	struct v4l2_mbus_framefmt fmt[STF_CSI_PADS_NUM];
	const struct csi_format *formats;
	unsigned int nformats;
	struct csi_hw_ops *hw_ops;
	struct mutex stream_lock;
	int stream_count;
};

extern int stf_csi_subdev_init(struct stfcamss *stfcamss, int id);
extern int stf_csi_register(struct stf_csi_dev *csi_dev,
			struct v4l2_device *v4l2_dev);
extern int stf_csi_unregister(struct stf_csi_dev *csi_dev);
extern int raw_csi2rx_dphy_config(struct stf_vin_dev *vin,
			const csi2rx_dphy_cfg_t *cfg);
extern int raw_csi2rx_config(struct stf_vin_dev *vin,
			int id,
			const csi2rx_cfg_t *cfg);
extern struct csi_hw_ops csi_ops;
extern void dump_csi_reg(void *__iomem csibase, int id);

#endif /* STF_CSI_H */