1 /* SPDX-License-Identifier: GPL-2.0 */
5 * Qualcomm MSM Camera Subsystem - VFE (Video Front End) Module
7 * Copyright (c) 2013-2015, The Linux Foundation. All rights reserved.
8 * Copyright (C) 2015-2018 Linaro Ltd.
10 #ifndef QC_MSM_CAMSS_VFE_H
11 #define QC_MSM_CAMSS_VFE_H
13 #include <linux/clk.h>
14 #include <linux/spinlock_types.h>
15 #include <media/media-entity.h>
16 #include <media/v4l2-device.h>
17 #include <media/v4l2-subdev.h>
19 #include "camss-video.h"
21 #define MSM_VFE_PAD_SINK 0
22 #define MSM_VFE_PAD_SRC 1
23 #define MSM_VFE_PADS_NUM 2
25 #define MSM_VFE_LINE_NUM 4
26 #define MSM_VFE_IMAGE_MASTERS_NUM 7
27 #define MSM_VFE_COMPOSITE_IRQ_NUM 4
29 enum vfe_output_state {
33 VFE_OUTPUT_CONTINUOUS,
51 struct camss_buffer *buf[2];
52 struct camss_buffer *last_buffer;
53 struct list_head pending_bufs;
55 unsigned int drop_update_idx;
57 enum vfe_output_state state;
58 unsigned int sequence;
61 struct completion sof;
62 struct completion reg_update;
67 struct v4l2_subdev subdev;
68 struct media_pad pads[MSM_VFE_PADS_NUM];
69 struct v4l2_mbus_framefmt fmt[MSM_VFE_PADS_NUM];
70 struct v4l2_rect compose;
71 struct v4l2_rect crop;
72 struct camss_video video_out;
73 struct vfe_output output;
74 const struct vfe_format *formats;
75 unsigned int nformats;
81 void (*hw_version_read)(struct vfe_device *vfe, struct device *dev);
82 u16 (*get_ub_size)(u8 vfe_id);
83 void (*global_reset)(struct vfe_device *vfe);
84 void (*halt_request)(struct vfe_device *vfe);
85 void (*halt_clear)(struct vfe_device *vfe);
86 void (*wm_enable)(struct vfe_device *vfe, u8 wm, u8 enable);
87 void (*wm_frame_based)(struct vfe_device *vfe, u8 wm, u8 enable);
88 void (*wm_line_based)(struct vfe_device *vfe, u32 wm,
89 struct v4l2_pix_format_mplane *pix,
90 u8 plane, u32 enable);
91 void (*wm_set_framedrop_period)(struct vfe_device *vfe, u8 wm, u8 per);
92 void (*wm_set_framedrop_pattern)(struct vfe_device *vfe, u8 wm,
94 void (*wm_set_ub_cfg)(struct vfe_device *vfe, u8 wm, u16 offset,
96 void (*bus_reload_wm)(struct vfe_device *vfe, u8 wm);
97 void (*wm_set_ping_addr)(struct vfe_device *vfe, u8 wm, u32 addr);
98 void (*wm_set_pong_addr)(struct vfe_device *vfe, u8 wm, u32 addr);
99 int (*wm_get_ping_pong_status)(struct vfe_device *vfe, u8 wm);
100 void (*bus_enable_wr_if)(struct vfe_device *vfe, u8 enable);
101 void (*bus_connect_wm_to_rdi)(struct vfe_device *vfe, u8 wm,
102 enum vfe_line_id id);
103 void (*wm_set_subsample)(struct vfe_device *vfe, u8 wm);
104 void (*bus_disconnect_wm_from_rdi)(struct vfe_device *vfe, u8 wm,
105 enum vfe_line_id id);
106 void (*set_xbar_cfg)(struct vfe_device *vfe, struct vfe_output *output,
108 void (*set_rdi_cid)(struct vfe_device *vfe, enum vfe_line_id id,
110 void (*set_realign_cfg)(struct vfe_device *vfe, struct vfe_line *line,
112 void (*reg_update)(struct vfe_device *vfe, enum vfe_line_id line_id);
113 void (*reg_update_clear)(struct vfe_device *vfe,
114 enum vfe_line_id line_id);
115 void (*enable_irq_wm_line)(struct vfe_device *vfe, u8 wm,
116 enum vfe_line_id line_id, u8 enable);
117 void (*enable_irq_pix_line)(struct vfe_device *vfe, u8 comp,
118 enum vfe_line_id line_id, u8 enable);
119 void (*enable_irq_common)(struct vfe_device *vfe);
120 void (*set_demux_cfg)(struct vfe_device *vfe, struct vfe_line *line);
121 void (*set_scale_cfg)(struct vfe_device *vfe, struct vfe_line *line);
122 void (*set_crop_cfg)(struct vfe_device *vfe, struct vfe_line *line);
123 void (*set_clamp_cfg)(struct vfe_device *vfe);
124 void (*set_qos)(struct vfe_device *vfe);
125 void (*set_ds)(struct vfe_device *vfe);
126 void (*set_cgc_override)(struct vfe_device *vfe, u8 wm, u8 enable);
127 void (*set_camif_cfg)(struct vfe_device *vfe, struct vfe_line *line);
128 void (*set_camif_cmd)(struct vfe_device *vfe, u8 enable);
129 void (*set_module_cfg)(struct vfe_device *vfe, u8 enable);
130 int (*camif_wait_for_stop)(struct vfe_device *vfe, struct device *dev);
131 void (*isr_read)(struct vfe_device *vfe, u32 *value0, u32 *value1);
132 void (*violation_read)(struct vfe_device *vfe);
133 irqreturn_t (*isr)(int irq, void *dev);
137 void (*reset_ack)(struct vfe_device *vfe);
138 void (*halt_ack)(struct vfe_device *vfe);
139 void (*reg_update)(struct vfe_device *vfe, enum vfe_line_id line_id);
140 void (*sof)(struct vfe_device *vfe, enum vfe_line_id line_id);
141 void (*comp_done)(struct vfe_device *vfe, u8 comp);
142 void (*wm_done)(struct vfe_device *vfe, u8 wm);
151 struct camss_clock *clock;
153 struct completion reset_complete;
154 struct completion halt_complete;
155 struct mutex power_lock;
157 struct mutex stream_lock;
159 spinlock_t output_lock;
160 enum vfe_line_id wm_output_map[MSM_VFE_IMAGE_MASTERS_NUM];
161 struct vfe_line line[MSM_VFE_LINE_NUM];
164 const struct vfe_hw_ops *ops;
165 struct vfe_isr_ops isr_ops;
170 int msm_vfe_subdev_init(struct camss *camss, struct vfe_device *vfe,
171 const struct resources *res, u8 id);
173 int msm_vfe_register_entities(struct vfe_device *vfe,
174 struct v4l2_device *v4l2_dev);
176 void msm_vfe_unregister_entities(struct vfe_device *vfe);
178 void msm_vfe_get_vfe_id(struct media_entity *entity, u8 *id);
179 void msm_vfe_get_vfe_line_id(struct media_entity *entity, enum vfe_line_id *id);
181 void msm_vfe_stop_streaming(struct vfe_device *vfe);
183 extern const struct vfe_hw_ops vfe_ops_4_1;
184 extern const struct vfe_hw_ops vfe_ops_4_7;
186 #endif /* QC_MSM_CAMSS_VFE_H */