1*633b388fSRobert Foss /* SPDX-License-Identifier: GPL-2.0 */
2*633b388fSRobert Foss /*
3*633b388fSRobert Foss * camss-vfe.h
4*633b388fSRobert Foss *
5*633b388fSRobert Foss * Qualcomm MSM Camera Subsystem - VFE (Video Front End) Module
6*633b388fSRobert Foss *
7*633b388fSRobert Foss * Copyright (c) 2013-2015, The Linux Foundation. All rights reserved.
8*633b388fSRobert Foss * Copyright (C) 2015-2018 Linaro Ltd.
9*633b388fSRobert Foss */
10*633b388fSRobert Foss #ifndef QC_MSM_CAMSS_VFE_GEN1_H
11*633b388fSRobert Foss #define QC_MSM_CAMSS_VFE_GEN1_H
12*633b388fSRobert Foss
13*633b388fSRobert Foss #include "camss-vfe.h"
14*633b388fSRobert Foss
15*633b388fSRobert Foss enum vfe_line_id;
16*633b388fSRobert Foss struct vfe_device;
17*633b388fSRobert Foss struct vfe_line;
18*633b388fSRobert Foss struct vfe_output;
19*633b388fSRobert Foss
20*633b388fSRobert Foss struct vfe_hw_ops_gen1 {
21*633b388fSRobert Foss void (*bus_connect_wm_to_rdi)(struct vfe_device *vfe, u8 wm, enum vfe_line_id id);
22*633b388fSRobert Foss void (*bus_disconnect_wm_from_rdi)(struct vfe_device *vfe, u8 wm, enum vfe_line_id id);
23*633b388fSRobert Foss void (*bus_enable_wr_if)(struct vfe_device *vfe, u8 enable);
24*633b388fSRobert Foss void (*bus_reload_wm)(struct vfe_device *vfe, u8 wm);
25*633b388fSRobert Foss int (*camif_wait_for_stop)(struct vfe_device *vfe, struct device *dev);
26*633b388fSRobert Foss void (*enable_irq_common)(struct vfe_device *vfe);
27*633b388fSRobert Foss void (*enable_irq_wm_line)(struct vfe_device *vfe, u8 wm, enum vfe_line_id line_id,
28*633b388fSRobert Foss u8 enable);
29*633b388fSRobert Foss void (*enable_irq_pix_line)(struct vfe_device *vfe, u8 comp, enum vfe_line_id line_id,
30*633b388fSRobert Foss u8 enable);
31*633b388fSRobert Foss u16 (*get_ub_size)(u8 vfe_id);
32*633b388fSRobert Foss void (*halt_clear)(struct vfe_device *vfe);
33*633b388fSRobert Foss void (*halt_request)(struct vfe_device *vfe);
34*633b388fSRobert Foss void (*set_camif_cfg)(struct vfe_device *vfe, struct vfe_line *line);
35*633b388fSRobert Foss void (*set_camif_cmd)(struct vfe_device *vfe, u8 enable);
36*633b388fSRobert Foss void (*set_cgc_override)(struct vfe_device *vfe, u8 wm, u8 enable);
37*633b388fSRobert Foss void (*set_clamp_cfg)(struct vfe_device *vfe);
38*633b388fSRobert Foss void (*set_crop_cfg)(struct vfe_device *vfe, struct vfe_line *line);
39*633b388fSRobert Foss void (*set_demux_cfg)(struct vfe_device *vfe, struct vfe_line *line);
40*633b388fSRobert Foss void (*set_ds)(struct vfe_device *vfe);
41*633b388fSRobert Foss void (*set_module_cfg)(struct vfe_device *vfe, u8 enable);
42*633b388fSRobert Foss void (*set_scale_cfg)(struct vfe_device *vfe, struct vfe_line *line);
43*633b388fSRobert Foss void (*set_rdi_cid)(struct vfe_device *vfe, enum vfe_line_id id, u8 cid);
44*633b388fSRobert Foss void (*set_realign_cfg)(struct vfe_device *vfe, struct vfe_line *line, u8 enable);
45*633b388fSRobert Foss void (*set_qos)(struct vfe_device *vfe);
46*633b388fSRobert Foss void (*set_xbar_cfg)(struct vfe_device *vfe, struct vfe_output *output, u8 enable);
47*633b388fSRobert Foss void (*wm_frame_based)(struct vfe_device *vfe, u8 wm, u8 enable);
48*633b388fSRobert Foss void (*wm_line_based)(struct vfe_device *vfe, u32 wm, struct v4l2_pix_format_mplane *pix,
49*633b388fSRobert Foss u8 plane, u32 enable);
50*633b388fSRobert Foss void (*wm_set_ub_cfg)(struct vfe_device *vfe, u8 wm, u16 offset, u16 depth);
51*633b388fSRobert Foss void (*wm_set_subsample)(struct vfe_device *vfe, u8 wm);
52*633b388fSRobert Foss void (*wm_set_framedrop_period)(struct vfe_device *vfe, u8 wm, u8 per);
53*633b388fSRobert Foss void (*wm_set_framedrop_pattern)(struct vfe_device *vfe, u8 wm, u32 pattern);
54*633b388fSRobert Foss void (*wm_set_ping_addr)(struct vfe_device *vfe, u8 wm, u32 addr);
55*633b388fSRobert Foss void (*wm_set_pong_addr)(struct vfe_device *vfe, u8 wm, u32 addr);
56*633b388fSRobert Foss int (*wm_get_ping_pong_status)(struct vfe_device *vfe, u8 wm);
57*633b388fSRobert Foss void (*wm_enable)(struct vfe_device *vfe, u8 wm, u8 enable);
58*633b388fSRobert Foss };
59*633b388fSRobert Foss
60*633b388fSRobert Foss /*
61*633b388fSRobert Foss * vfe_calc_interp_reso - Calculate interpolation mode
62*633b388fSRobert Foss * @input: Input resolution
63*633b388fSRobert Foss * @output: Output resolution
64*633b388fSRobert Foss *
65*633b388fSRobert Foss * Return interpolation mode
66*633b388fSRobert Foss */
vfe_calc_interp_reso(u16 input,u16 output)67*633b388fSRobert Foss static inline u8 vfe_calc_interp_reso(u16 input, u16 output)
68*633b388fSRobert Foss {
69*633b388fSRobert Foss if (input / output >= 16)
70*633b388fSRobert Foss return 0;
71*633b388fSRobert Foss
72*633b388fSRobert Foss if (input / output >= 8)
73*633b388fSRobert Foss return 1;
74*633b388fSRobert Foss
75*633b388fSRobert Foss if (input / output >= 4)
76*633b388fSRobert Foss return 2;
77*633b388fSRobert Foss
78*633b388fSRobert Foss return 3;
79*633b388fSRobert Foss }
80*633b388fSRobert Foss
81*633b388fSRobert Foss /*
82*633b388fSRobert Foss * vfe_gen1_disable - Disable streaming on VFE line
83*633b388fSRobert Foss * @line: VFE line
84*633b388fSRobert Foss *
85*633b388fSRobert Foss * Return 0 on success or a negative error code otherwise
86*633b388fSRobert Foss */
87*633b388fSRobert Foss int vfe_gen1_disable(struct vfe_line *line);
88*633b388fSRobert Foss
89*633b388fSRobert Foss /*
90*633b388fSRobert Foss * vfe_gen1_enable - Enable VFE module
91*633b388fSRobert Foss * @line: VFE line
92*633b388fSRobert Foss *
93*633b388fSRobert Foss * Return 0 on success
94*633b388fSRobert Foss */
95*633b388fSRobert Foss int vfe_gen1_enable(struct vfe_line *line);
96*633b388fSRobert Foss
97*633b388fSRobert Foss /*
98*633b388fSRobert Foss * vfe_gen1_enable - Halt VFE module
99*633b388fSRobert Foss * @vfe: VFE device
100*633b388fSRobert Foss *
101*633b388fSRobert Foss * Return 0 on success
102*633b388fSRobert Foss */
103*633b388fSRobert Foss int vfe_gen1_halt(struct vfe_device *vfe);
104*633b388fSRobert Foss
105*633b388fSRobert Foss /*
106*633b388fSRobert Foss * vfe_word_per_line - Calculate number of words per frame width
107*633b388fSRobert Foss * @format: V4L2 format
108*633b388fSRobert Foss * @width: Frame width
109*633b388fSRobert Foss *
110*633b388fSRobert Foss * Return number of words per frame width
111*633b388fSRobert Foss */
112*633b388fSRobert Foss int vfe_word_per_line(u32 format, u32 width);
113*633b388fSRobert Foss
114*633b388fSRobert Foss extern const struct vfe_isr_ops vfe_isr_ops_gen1;
115*633b388fSRobert Foss extern const struct camss_video_ops vfe_video_ops_gen1;
116*633b388fSRobert Foss
117*633b388fSRobert Foss #endif /* QC_MSM_CAMSS_VFE_GEN1_H */
118