162306a36Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0 */ 262306a36Sopenharmony_ci/* 362306a36Sopenharmony_ci * camss-vfe.h 462306a36Sopenharmony_ci * 562306a36Sopenharmony_ci * Qualcomm MSM Camera Subsystem - VFE (Video Front End) Module 662306a36Sopenharmony_ci * 762306a36Sopenharmony_ci * Copyright (c) 2013-2015, The Linux Foundation. All rights reserved. 862306a36Sopenharmony_ci * Copyright (C) 2015-2018 Linaro Ltd. 962306a36Sopenharmony_ci */ 1062306a36Sopenharmony_ci#ifndef QC_MSM_CAMSS_VFE_GEN1_H 1162306a36Sopenharmony_ci#define QC_MSM_CAMSS_VFE_GEN1_H 1262306a36Sopenharmony_ci 1362306a36Sopenharmony_ci#include "camss-vfe.h" 1462306a36Sopenharmony_ci 1562306a36Sopenharmony_cienum vfe_line_id; 1662306a36Sopenharmony_cistruct vfe_device; 1762306a36Sopenharmony_cistruct vfe_line; 1862306a36Sopenharmony_cistruct vfe_output; 1962306a36Sopenharmony_ci 2062306a36Sopenharmony_cistruct vfe_hw_ops_gen1 { 2162306a36Sopenharmony_ci void (*bus_connect_wm_to_rdi)(struct vfe_device *vfe, u8 wm, enum vfe_line_id id); 2262306a36Sopenharmony_ci void (*bus_disconnect_wm_from_rdi)(struct vfe_device *vfe, u8 wm, enum vfe_line_id id); 2362306a36Sopenharmony_ci void (*bus_enable_wr_if)(struct vfe_device *vfe, u8 enable); 2462306a36Sopenharmony_ci void (*bus_reload_wm)(struct vfe_device *vfe, u8 wm); 2562306a36Sopenharmony_ci int (*camif_wait_for_stop)(struct vfe_device *vfe, struct device *dev); 2662306a36Sopenharmony_ci void (*enable_irq_common)(struct vfe_device *vfe); 2762306a36Sopenharmony_ci void (*enable_irq_wm_line)(struct vfe_device *vfe, u8 wm, enum vfe_line_id line_id, 2862306a36Sopenharmony_ci u8 enable); 2962306a36Sopenharmony_ci void (*enable_irq_pix_line)(struct vfe_device *vfe, u8 comp, enum vfe_line_id line_id, 3062306a36Sopenharmony_ci u8 enable); 3162306a36Sopenharmony_ci u16 (*get_ub_size)(u8 vfe_id); 3262306a36Sopenharmony_ci void (*halt_clear)(struct vfe_device *vfe); 3362306a36Sopenharmony_ci void (*halt_request)(struct vfe_device *vfe); 3462306a36Sopenharmony_ci void (*set_camif_cfg)(struct vfe_device *vfe, struct vfe_line *line); 3562306a36Sopenharmony_ci void (*set_camif_cmd)(struct vfe_device *vfe, u8 enable); 3662306a36Sopenharmony_ci void (*set_cgc_override)(struct vfe_device *vfe, u8 wm, u8 enable); 3762306a36Sopenharmony_ci void (*set_clamp_cfg)(struct vfe_device *vfe); 3862306a36Sopenharmony_ci void (*set_crop_cfg)(struct vfe_device *vfe, struct vfe_line *line); 3962306a36Sopenharmony_ci void (*set_demux_cfg)(struct vfe_device *vfe, struct vfe_line *line); 4062306a36Sopenharmony_ci void (*set_ds)(struct vfe_device *vfe); 4162306a36Sopenharmony_ci void (*set_module_cfg)(struct vfe_device *vfe, u8 enable); 4262306a36Sopenharmony_ci void (*set_scale_cfg)(struct vfe_device *vfe, struct vfe_line *line); 4362306a36Sopenharmony_ci void (*set_rdi_cid)(struct vfe_device *vfe, enum vfe_line_id id, u8 cid); 4462306a36Sopenharmony_ci void (*set_realign_cfg)(struct vfe_device *vfe, struct vfe_line *line, u8 enable); 4562306a36Sopenharmony_ci void (*set_qos)(struct vfe_device *vfe); 4662306a36Sopenharmony_ci void (*set_xbar_cfg)(struct vfe_device *vfe, struct vfe_output *output, u8 enable); 4762306a36Sopenharmony_ci void (*wm_frame_based)(struct vfe_device *vfe, u8 wm, u8 enable); 4862306a36Sopenharmony_ci void (*wm_line_based)(struct vfe_device *vfe, u32 wm, struct v4l2_pix_format_mplane *pix, 4962306a36Sopenharmony_ci u8 plane, u32 enable); 5062306a36Sopenharmony_ci void (*wm_set_ub_cfg)(struct vfe_device *vfe, u8 wm, u16 offset, u16 depth); 5162306a36Sopenharmony_ci void (*wm_set_subsample)(struct vfe_device *vfe, u8 wm); 5262306a36Sopenharmony_ci void (*wm_set_framedrop_period)(struct vfe_device *vfe, u8 wm, u8 per); 5362306a36Sopenharmony_ci void (*wm_set_framedrop_pattern)(struct vfe_device *vfe, u8 wm, u32 pattern); 5462306a36Sopenharmony_ci void (*wm_set_ping_addr)(struct vfe_device *vfe, u8 wm, u32 addr); 5562306a36Sopenharmony_ci void (*wm_set_pong_addr)(struct vfe_device *vfe, u8 wm, u32 addr); 5662306a36Sopenharmony_ci int (*wm_get_ping_pong_status)(struct vfe_device *vfe, u8 wm); 5762306a36Sopenharmony_ci void (*wm_enable)(struct vfe_device *vfe, u8 wm, u8 enable); 5862306a36Sopenharmony_ci}; 5962306a36Sopenharmony_ci 6062306a36Sopenharmony_ci/* 6162306a36Sopenharmony_ci * vfe_calc_interp_reso - Calculate interpolation mode 6262306a36Sopenharmony_ci * @input: Input resolution 6362306a36Sopenharmony_ci * @output: Output resolution 6462306a36Sopenharmony_ci * 6562306a36Sopenharmony_ci * Return interpolation mode 6662306a36Sopenharmony_ci */ 6762306a36Sopenharmony_cistatic inline u8 vfe_calc_interp_reso(u16 input, u16 output) 6862306a36Sopenharmony_ci{ 6962306a36Sopenharmony_ci if (input / output >= 16) 7062306a36Sopenharmony_ci return 0; 7162306a36Sopenharmony_ci 7262306a36Sopenharmony_ci if (input / output >= 8) 7362306a36Sopenharmony_ci return 1; 7462306a36Sopenharmony_ci 7562306a36Sopenharmony_ci if (input / output >= 4) 7662306a36Sopenharmony_ci return 2; 7762306a36Sopenharmony_ci 7862306a36Sopenharmony_ci return 3; 7962306a36Sopenharmony_ci} 8062306a36Sopenharmony_ci 8162306a36Sopenharmony_ci/* 8262306a36Sopenharmony_ci * vfe_gen1_disable - Disable streaming on VFE line 8362306a36Sopenharmony_ci * @line: VFE line 8462306a36Sopenharmony_ci * 8562306a36Sopenharmony_ci * Return 0 on success or a negative error code otherwise 8662306a36Sopenharmony_ci */ 8762306a36Sopenharmony_ciint vfe_gen1_disable(struct vfe_line *line); 8862306a36Sopenharmony_ci 8962306a36Sopenharmony_ci/* 9062306a36Sopenharmony_ci * vfe_gen1_enable - Enable VFE module 9162306a36Sopenharmony_ci * @line: VFE line 9262306a36Sopenharmony_ci * 9362306a36Sopenharmony_ci * Return 0 on success 9462306a36Sopenharmony_ci */ 9562306a36Sopenharmony_ciint vfe_gen1_enable(struct vfe_line *line); 9662306a36Sopenharmony_ci 9762306a36Sopenharmony_ci/* 9862306a36Sopenharmony_ci * vfe_gen1_enable - Halt VFE module 9962306a36Sopenharmony_ci * @vfe: VFE device 10062306a36Sopenharmony_ci * 10162306a36Sopenharmony_ci * Return 0 on success 10262306a36Sopenharmony_ci */ 10362306a36Sopenharmony_ciint vfe_gen1_halt(struct vfe_device *vfe); 10462306a36Sopenharmony_ci 10562306a36Sopenharmony_ci/* 10662306a36Sopenharmony_ci * vfe_word_per_line - Calculate number of words per frame width 10762306a36Sopenharmony_ci * @format: V4L2 format 10862306a36Sopenharmony_ci * @width: Frame width 10962306a36Sopenharmony_ci * 11062306a36Sopenharmony_ci * Return number of words per frame width 11162306a36Sopenharmony_ci */ 11262306a36Sopenharmony_ciint vfe_word_per_line(u32 format, u32 width); 11362306a36Sopenharmony_ci 11462306a36Sopenharmony_ciextern const struct vfe_isr_ops vfe_isr_ops_gen1; 11562306a36Sopenharmony_ciextern const struct camss_video_ops vfe_video_ops_gen1; 11662306a36Sopenharmony_ci 11762306a36Sopenharmony_ci#endif /* QC_MSM_CAMSS_VFE_GEN1_H */ 118