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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
|
// SPDX-License-Identifier: GPL-2.0
/*
* Copyright (C) 2021 StarFive Technology Co., Ltd.
*/
#ifndef STF_VIN_H
#define STF_VIN_H
#include <media/v4l2-device.h>
#include <media/v4l2-subdev.h>
#include <linux/spinlock_types.h>
#include <video/stf-vin.h>
#include <linux/platform_device.h>
#include "stf_video.h"
#define STF_VIN_PAD_SINK 0
#define STF_VIN_PAD_SRC 1
#define STF_VIN_PADS_NUM 2
struct vin2_format {
u32 code;
u8 bpp;
};
enum vin_output_state {
VIN_OUTPUT_OFF,
VIN_OUTPUT_RESERVED,
VIN_OUTPUT_SINGLE,
VIN_OUTPUT_CONTINUOUS,
VIN_OUTPUT_IDLE,
VIN_OUTPUT_STOPPING
};
struct vin_output {
int active_buf;
struct stfcamss_buffer *buf[2];
struct stfcamss_buffer *last_buffer;
struct list_head pending_bufs;
enum vin_output_state state;
unsigned int sequence;
unsigned int frame_skip;
};
enum vin_line_id {
VIN_LINE_NONE = -1,
VIN_LINE_WR = 0,
VIN_LINE_ISP0 = 1,
VIN_LINE_ISP1 = 2,
VIN_LINE_ISP0_RAW = 3,
VIN_LINE_ISP1_RAW = 4,
VIN_LINE_MAX = 5
};
enum subdev_type;
struct vin_line {
enum subdev_type sdev_type; // must be frist
enum vin_line_id id;
struct v4l2_subdev subdev;
struct media_pad pads[STF_VIN_PADS_NUM];
struct v4l2_mbus_framefmt fmt[STF_VIN_PADS_NUM];
struct stfcamss_video video_out;
struct mutex stream_lock;
int stream_count;
struct mutex power_lock;
int power_count;
struct vin_output output;
spinlock_t output_lock;
const struct vin2_format *formats;
unsigned int nformats;
};
struct stf_vin2_dev;
struct vin_hw_ops {
int (*vin_clk_init)(struct stf_vin2_dev *vin_dev);
int (*vin_clk_enable)(struct stf_vin2_dev *vin_dev);
int (*vin_clk_disable)(struct stf_vin2_dev *vin_dev);
int (*vin_config_set)(struct stf_vin2_dev *vin_dev);
int (*vin_wr_stream_set)(struct stf_vin2_dev *vin_dev, int on);
void (*vin_wr_irq_enable)(struct stf_vin2_dev *vin_dev, int enable);
void (*wr_rd_set_addr)(struct stf_vin2_dev *vin_dev,
dma_addr_t wr_addr, dma_addr_t rd_addr);
void (*vin_wr_set_ping_addr)(struct stf_vin2_dev *vin_dev,
dma_addr_t addr);
void (*vin_wr_set_pong_addr)(struct stf_vin2_dev *vin_dev,
dma_addr_t addr);
void (*vin_wr_get_ping_pong_status)(struct stf_vin2_dev *vin_dev);
void (*vin_isp_set_yuv_addr)(struct stf_vin2_dev *vin_dev,
int isp_id,
dma_addr_t y_addr, dma_addr_t uv_addr);
void (*vin_isp_set_raw_addr)(struct stf_vin2_dev *vin_dev,
int isp_id, dma_addr_t raw_addr);
irqreturn_t (*vin_wr_irq_handler)(int irq, void *priv);
irqreturn_t (*vin_isp_irq_handler)(int irq, void *priv);
void (*isr_buffer_done)(struct vin_line *line,
struct vin_params *params);
};
struct stf_vin2_dev {
struct stfcamss *stfcamss;
u8 id;
struct vin_line line[VIN_LINE_MAX];
struct vin_hw_ops *hw_ops;
atomic_t ref_count;
struct mutex power_lock;
int power_count;
};
extern int stf_vin_subdev_init(struct stfcamss *stfcamss);
extern int stf_vin_register(struct stf_vin2_dev *vin_dev,
struct v4l2_device *v4l2_dev);
extern int stf_vin_unregister(struct stf_vin2_dev *vin_dev);
extern struct vin_hw_ops vin_ops;
extern void dump_vin_reg(void *__iomem regbase);
#endif /* STF_VIN_H */
|