Lines Matching +full:output +full:- +full:enable
1 // SPDX-License-Identifier: GPL-2.0
3 * camss-vfe-4-7.c
5 * Qualcomm MSM Camera Subsystem - VFE (Video Front End) Module v4.7
7 * Copyright (c) 2013-2015, The Linux Foundation. All rights reserved.
8 * Copyright (C) 2015-2018 Linaro Ltd.
17 #include "camss-vfe.h"
18 #include "camss-vfe-gen1.h"
259 u32 hw_version = readl_relaxed(vfe->base + VFE_0_HW_VERSION); in vfe_hw_version()
261 dev_dbg(vfe->camss->dev, "VFE HW Version = 0x%08x\n", hw_version); in vfe_hw_version()
278 u32 bits = readl_relaxed(vfe->base + reg); in vfe_reg_clr()
280 writel_relaxed(bits & ~clr_bits, vfe->base + reg); in vfe_reg_clr()
285 u32 bits = readl_relaxed(vfe->base + reg); in vfe_reg_set()
287 writel_relaxed(bits | set_bits, vfe->base + reg); in vfe_reg_set()
303 writel_relaxed(BIT(31), vfe->base + VFE_0_IRQ_MASK_0); in vfe_global_reset()
307 writel_relaxed(reset_bits, vfe->base + VFE_0_GLOBAL_RESET_CMD); in vfe_global_reset()
313 vfe->base + VFE_0_BUS_BDG_CMD); in vfe_halt_request()
318 writel_relaxed(0x0, vfe->base + VFE_0_BUS_BDG_CMD); in vfe_halt_clear()
321 static void vfe_wm_enable(struct vfe_device *vfe, u8 wm, u8 enable) in vfe_wm_enable() argument
323 if (enable) in vfe_wm_enable()
331 static void vfe_wm_frame_based(struct vfe_device *vfe, u8 wm, u8 enable) in vfe_wm_frame_based() argument
333 if (enable) in vfe_wm_frame_based()
341 #define CALC_WORD(width, M, N) (((width) * (M) + (N) - 1) / (N))
373 *width = pix->width; in vfe_get_wm_sizes()
374 *height = pix->height; in vfe_get_wm_sizes()
376 switch (pix->pixelformat) { in vfe_get_wm_sizes()
379 *bytesperline = pix->plane_fmt[0].bytesperline; in vfe_get_wm_sizes()
385 *bytesperline = pix->plane_fmt[0].bytesperline; in vfe_get_wm_sizes()
391 *bytesperline = pix->plane_fmt[plane].bytesperline; in vfe_get_wm_sizes()
398 u8 plane, u32 enable) in vfe_wm_line_based() argument
402 if (enable) { in vfe_wm_line_based()
407 wpl = vfe_word_per_line_by_pixel(pix->pixelformat, width); in vfe_wm_line_based()
409 reg = height - 1; in vfe_wm_line_based()
410 reg |= ((wpl + 3) / 4 - 1) << 16; in vfe_wm_line_based()
412 writel_relaxed(reg, vfe->base + in vfe_wm_line_based()
418 reg |= (height - 1) << 2; in vfe_wm_line_based()
421 writel_relaxed(reg, vfe->base + in vfe_wm_line_based()
424 writel_relaxed(0, vfe->base + in vfe_wm_line_based()
426 writel_relaxed(0, vfe->base + in vfe_wm_line_based()
435 reg = readl_relaxed(vfe->base + in vfe_wm_set_framedrop_period()
444 vfe->base + VFE_0_BUS_IMAGE_MASTER_n_WR_ADDR_CFG(wm)); in vfe_wm_set_framedrop_period()
451 vfe->base + VFE_0_BUS_IMAGE_MASTER_n_WR_FRAMEDROP_PATTERN(wm)); in vfe_wm_set_framedrop_pattern()
461 writel_relaxed(reg, vfe->base + VFE_0_BUS_IMAGE_MASTER_n_WR_UB_CFG(wm)); in vfe_wm_set_ub_cfg()
469 writel_relaxed(VFE_0_BUS_CMD_Mx_RLD_CMD(wm), vfe->base + VFE_0_BUS_CMD); in vfe_bus_reload_wm()
478 vfe->base + VFE_0_BUS_IMAGE_MASTER_n_WR_PING_ADDR(wm)); in vfe_wm_set_ping_addr()
484 vfe->base + VFE_0_BUS_IMAGE_MASTER_n_WR_PONG_ADDR(wm)); in vfe_wm_set_pong_addr()
491 reg = readl_relaxed(vfe->base + VFE_0_BUS_PING_PONG_STATUS); in vfe_wm_get_ping_pong_status()
496 static void vfe_bus_enable_wr_if(struct vfe_device *vfe, u8 enable) in vfe_bus_enable_wr_if() argument
498 if (enable) in vfe_bus_enable_wr_if()
499 writel_relaxed(0x101, vfe->base + VFE_0_BUS_CFG); in vfe_bus_enable_wr_if()
501 writel_relaxed(0, vfe->base + VFE_0_BUS_CFG); in vfe_bus_enable_wr_if()
542 vfe->base + in vfe_wm_set_subsample()
576 static void vfe_set_xbar_cfg(struct vfe_device *vfe, struct vfe_output *output, in vfe_set_xbar_cfg() argument
577 u8 enable) in vfe_set_xbar_cfg() argument
579 struct vfe_line *line = container_of(output, struct vfe_line, output); in vfe_set_xbar_cfg()
580 u32 p = line->video_out.active_fmt.fmt.pix_mp.pixelformat; in vfe_set_xbar_cfg()
591 if (output->wm_idx[0] % 2 == 1) in vfe_set_xbar_cfg()
594 if (enable) in vfe_set_xbar_cfg()
596 VFE_0_BUS_XBAR_CFG_x(output->wm_idx[0]), in vfe_set_xbar_cfg()
600 VFE_0_BUS_XBAR_CFG_x(output->wm_idx[0]), in vfe_set_xbar_cfg()
607 if (output->wm_idx[1] % 2 == 1) in vfe_set_xbar_cfg()
610 if (enable) in vfe_set_xbar_cfg()
612 VFE_0_BUS_XBAR_CFG_x(output->wm_idx[1]), in vfe_set_xbar_cfg()
616 VFE_0_BUS_XBAR_CFG_x(output->wm_idx[1]), in vfe_set_xbar_cfg()
629 if (output->wm_idx[0] % 2 == 1) in vfe_set_xbar_cfg()
632 if (enable) in vfe_set_xbar_cfg()
634 VFE_0_BUS_XBAR_CFG_x(output->wm_idx[0]), in vfe_set_xbar_cfg()
638 VFE_0_BUS_XBAR_CFG_x(output->wm_idx[0]), in vfe_set_xbar_cfg()
647 u8 enable) in vfe_set_realign_cfg() argument
649 u32 p = line->video_out.active_fmt.fmt.pix_mp.pixelformat; in vfe_set_realign_cfg()
656 if (enable) { in vfe_set_realign_cfg()
670 writel_relaxed(val, vfe->base + VFE_0_REALIGN_BUF_CFG); in vfe_set_realign_cfg()
684 vfe->reg_update |= VFE_0_REG_UPDATE_line_n(line_id); in vfe_reg_update()
688 writel_relaxed(vfe->reg_update, vfe->base + VFE_0_REG_UPDATE); in vfe_reg_update()
697 vfe->reg_update &= ~VFE_0_REG_UPDATE_line_n(line_id); in vfe_reg_update_clear()
701 enum vfe_line_id line_id, u8 enable) in vfe_enable_irq_wm_line() argument
708 if (enable) { in vfe_enable_irq_wm_line()
718 enum vfe_line_id line_id, u8 enable) in vfe_enable_irq_pix_line() argument
720 struct vfe_output *output = &vfe->line[line_id].output; in vfe_enable_irq_pix_line() local
731 for (i = 0; i < output->wm_num; i++) { in vfe_enable_irq_pix_line()
733 output->wm_idx[i]); in vfe_enable_irq_pix_line()
734 comp_mask |= (1 << output->wm_idx[i]) << comp * 8; in vfe_enable_irq_pix_line()
737 if (enable) { in vfe_enable_irq_pix_line()
762 writel_relaxed(VFE_0_DEMUX_CFG_PERIOD, vfe->base + VFE_0_DEMUX_CFG); in vfe_set_demux_cfg()
765 writel_relaxed(val, vfe->base + VFE_0_DEMUX_GAIN_0); in vfe_set_demux_cfg()
768 writel_relaxed(val, vfe->base + VFE_0_DEMUX_GAIN_1); in vfe_set_demux_cfg()
770 switch (line->fmt[MSM_VFE_PAD_SINK].code) { in vfe_set_demux_cfg()
790 writel_relaxed(even_cfg, vfe->base + VFE_0_DEMUX_EVEN_CFG); in vfe_set_demux_cfg()
791 writel_relaxed(odd_cfg, vfe->base + VFE_0_DEMUX_ODD_CFG); in vfe_set_demux_cfg()
796 u32 p = line->video_out.active_fmt.fmt.pix_mp.pixelformat; in vfe_set_scale_cfg()
798 u16 input, output; in vfe_set_scale_cfg() local
802 writel_relaxed(0x3, vfe->base + VFE_0_SCALE_ENC_Y_CFG); in vfe_set_scale_cfg()
804 input = line->fmt[MSM_VFE_PAD_SINK].width - 1; in vfe_set_scale_cfg()
805 output = line->compose.width - 1; in vfe_set_scale_cfg()
806 reg = (output << 16) | input; in vfe_set_scale_cfg()
807 writel_relaxed(reg, vfe->base + VFE_0_SCALE_ENC_Y_H_IMAGE_SIZE); in vfe_set_scale_cfg()
809 interp_reso = vfe_calc_interp_reso(input, output); in vfe_set_scale_cfg()
810 phase_mult = input * (1 << (14 + interp_reso)) / output; in vfe_set_scale_cfg()
812 writel_relaxed(reg, vfe->base + VFE_0_SCALE_ENC_Y_H_PHASE); in vfe_set_scale_cfg()
814 input = line->fmt[MSM_VFE_PAD_SINK].height - 1; in vfe_set_scale_cfg()
815 output = line->compose.height - 1; in vfe_set_scale_cfg()
816 reg = (output << 16) | input; in vfe_set_scale_cfg()
817 writel_relaxed(reg, vfe->base + VFE_0_SCALE_ENC_Y_V_IMAGE_SIZE); in vfe_set_scale_cfg()
819 interp_reso = vfe_calc_interp_reso(input, output); in vfe_set_scale_cfg()
820 phase_mult = input * (1 << (14 + interp_reso)) / output; in vfe_set_scale_cfg()
822 writel_relaxed(reg, vfe->base + VFE_0_SCALE_ENC_Y_V_PHASE); in vfe_set_scale_cfg()
824 writel_relaxed(0x3, vfe->base + VFE_0_SCALE_ENC_CBCR_CFG); in vfe_set_scale_cfg()
826 input = line->fmt[MSM_VFE_PAD_SINK].width - 1; in vfe_set_scale_cfg()
827 output = line->compose.width / 2 - 1; in vfe_set_scale_cfg()
828 reg = (output << 16) | input; in vfe_set_scale_cfg()
829 writel_relaxed(reg, vfe->base + VFE_0_SCALE_ENC_CBCR_H_IMAGE_SIZE); in vfe_set_scale_cfg()
831 interp_reso = vfe_calc_interp_reso(input, output); in vfe_set_scale_cfg()
832 phase_mult = input * (1 << (14 + interp_reso)) / output; in vfe_set_scale_cfg()
834 writel_relaxed(reg, vfe->base + VFE_0_SCALE_ENC_CBCR_H_PHASE); in vfe_set_scale_cfg()
836 input = line->fmt[MSM_VFE_PAD_SINK].height - 1; in vfe_set_scale_cfg()
837 output = line->compose.height - 1; in vfe_set_scale_cfg()
839 output = line->compose.height / 2 - 1; in vfe_set_scale_cfg()
840 reg = (output << 16) | input; in vfe_set_scale_cfg()
841 writel_relaxed(reg, vfe->base + VFE_0_SCALE_ENC_CBCR_V_IMAGE_SIZE); in vfe_set_scale_cfg()
843 interp_reso = vfe_calc_interp_reso(input, output); in vfe_set_scale_cfg()
844 phase_mult = input * (1 << (14 + interp_reso)) / output; in vfe_set_scale_cfg()
846 writel_relaxed(reg, vfe->base + VFE_0_SCALE_ENC_CBCR_V_PHASE); in vfe_set_scale_cfg()
851 u32 p = line->video_out.active_fmt.fmt.pix_mp.pixelformat; in vfe_set_crop_cfg()
855 first = line->crop.left; in vfe_set_crop_cfg()
856 last = line->crop.left + line->crop.width - 1; in vfe_set_crop_cfg()
858 writel_relaxed(reg, vfe->base + VFE_0_CROP_ENC_Y_WIDTH); in vfe_set_crop_cfg()
860 first = line->crop.top; in vfe_set_crop_cfg()
861 last = line->crop.top + line->crop.height - 1; in vfe_set_crop_cfg()
863 writel_relaxed(reg, vfe->base + VFE_0_CROP_ENC_Y_HEIGHT); in vfe_set_crop_cfg()
865 first = line->crop.left / 2; in vfe_set_crop_cfg()
866 last = line->crop.left / 2 + line->crop.width / 2 - 1; in vfe_set_crop_cfg()
868 writel_relaxed(reg, vfe->base + VFE_0_CROP_ENC_CBCR_WIDTH); in vfe_set_crop_cfg()
870 first = line->crop.top; in vfe_set_crop_cfg()
871 last = line->crop.top + line->crop.height - 1; in vfe_set_crop_cfg()
873 first = line->crop.top / 2; in vfe_set_crop_cfg()
874 last = line->crop.top / 2 + line->crop.height / 2 - 1; in vfe_set_crop_cfg()
877 writel_relaxed(reg, vfe->base + VFE_0_CROP_ENC_CBCR_HEIGHT); in vfe_set_crop_cfg()
886 writel_relaxed(val, vfe->base + VFE_0_CLAMP_ENC_MAX_CFG); in vfe_set_clamp_cfg()
892 writel_relaxed(val, vfe->base + VFE_0_CLAMP_ENC_MIN_CFG); in vfe_set_clamp_cfg()
900 writel_relaxed(val, vfe->base + VFE_0_BUS_BDG_QOS_CFG_0); in vfe_set_qos()
901 writel_relaxed(val, vfe->base + VFE_0_BUS_BDG_QOS_CFG_1); in vfe_set_qos()
902 writel_relaxed(val, vfe->base + VFE_0_BUS_BDG_QOS_CFG_2); in vfe_set_qos()
903 writel_relaxed(val, vfe->base + VFE_0_BUS_BDG_QOS_CFG_3); in vfe_set_qos()
904 writel_relaxed(val, vfe->base + VFE_0_BUS_BDG_QOS_CFG_4); in vfe_set_qos()
905 writel_relaxed(val, vfe->base + VFE_0_BUS_BDG_QOS_CFG_5); in vfe_set_qos()
906 writel_relaxed(val, vfe->base + VFE_0_BUS_BDG_QOS_CFG_6); in vfe_set_qos()
907 writel_relaxed(val7, vfe->base + VFE_0_BUS_BDG_QOS_CFG_7); in vfe_set_qos()
915 writel_relaxed(val, vfe->base + VFE_0_BUS_BDG_DS_CFG_0); in vfe_set_ds()
916 writel_relaxed(val, vfe->base + VFE_0_BUS_BDG_DS_CFG_1); in vfe_set_ds()
917 writel_relaxed(val, vfe->base + VFE_0_BUS_BDG_DS_CFG_2); in vfe_set_ds()
918 writel_relaxed(val, vfe->base + VFE_0_BUS_BDG_DS_CFG_3); in vfe_set_ds()
919 writel_relaxed(val, vfe->base + VFE_0_BUS_BDG_DS_CFG_4); in vfe_set_ds()
920 writel_relaxed(val, vfe->base + VFE_0_BUS_BDG_DS_CFG_5); in vfe_set_ds()
921 writel_relaxed(val, vfe->base + VFE_0_BUS_BDG_DS_CFG_6); in vfe_set_ds()
922 writel_relaxed(val, vfe->base + VFE_0_BUS_BDG_DS_CFG_7); in vfe_set_ds()
923 writel_relaxed(val, vfe->base + VFE_0_BUS_BDG_DS_CFG_8); in vfe_set_ds()
924 writel_relaxed(val, vfe->base + VFE_0_BUS_BDG_DS_CFG_9); in vfe_set_ds()
925 writel_relaxed(val, vfe->base + VFE_0_BUS_BDG_DS_CFG_10); in vfe_set_ds()
926 writel_relaxed(val, vfe->base + VFE_0_BUS_BDG_DS_CFG_11); in vfe_set_ds()
927 writel_relaxed(val, vfe->base + VFE_0_BUS_BDG_DS_CFG_12); in vfe_set_ds()
928 writel_relaxed(val, vfe->base + VFE_0_BUS_BDG_DS_CFG_13); in vfe_set_ds()
929 writel_relaxed(val, vfe->base + VFE_0_BUS_BDG_DS_CFG_14); in vfe_set_ds()
930 writel_relaxed(val, vfe->base + VFE_0_BUS_BDG_DS_CFG_15); in vfe_set_ds()
931 writel_relaxed(val16, vfe->base + VFE_0_BUS_BDG_DS_CFG_16); in vfe_set_ds()
934 static void vfe_set_cgc_override(struct vfe_device *vfe, u8 wm, u8 enable) in vfe_set_cgc_override() argument
943 switch (line->fmt[MSM_VFE_PAD_SINK].code) { in vfe_set_camif_cfg()
960 writel_relaxed(val, vfe->base + VFE_0_CORE_CFG); in vfe_set_camif_cfg()
962 val = line->fmt[MSM_VFE_PAD_SINK].width * 2 - 1; in vfe_set_camif_cfg()
963 val |= (line->fmt[MSM_VFE_PAD_SINK].height - 1) << 16; in vfe_set_camif_cfg()
964 writel_relaxed(val, vfe->base + VFE_0_CAMIF_FRAME_CFG); in vfe_set_camif_cfg()
966 val = line->fmt[MSM_VFE_PAD_SINK].width * 2 - 1; in vfe_set_camif_cfg()
967 writel_relaxed(val, vfe->base + VFE_0_CAMIF_WINDOW_WIDTH_CFG); in vfe_set_camif_cfg()
969 val = line->fmt[MSM_VFE_PAD_SINK].height - 1; in vfe_set_camif_cfg()
970 writel_relaxed(val, vfe->base + VFE_0_CAMIF_WINDOW_HEIGHT_CFG); in vfe_set_camif_cfg()
973 writel_relaxed(val, vfe->base + VFE_0_CAMIF_SUBSAMPLE_CFG); in vfe_set_camif_cfg()
976 writel_relaxed(val, vfe->base + VFE_0_CAMIF_IRQ_FRAMEDROP_PATTERN); in vfe_set_camif_cfg()
979 writel_relaxed(val, vfe->base + VFE_0_CAMIF_IRQ_SUBSAMPLE_PATTERN); in vfe_set_camif_cfg()
985 writel_relaxed(val, vfe->base + VFE_0_CAMIF_CFG); in vfe_set_camif_cfg()
988 static void vfe_set_camif_cmd(struct vfe_device *vfe, u8 enable) in vfe_set_camif_cmd() argument
993 writel_relaxed(cmd, vfe->base + VFE_0_CAMIF_CMD); in vfe_set_camif_cmd()
998 if (enable) in vfe_set_camif_cmd()
1003 writel_relaxed(cmd, vfe->base + VFE_0_CAMIF_CMD); in vfe_set_camif_cmd()
1006 static void vfe_set_module_cfg(struct vfe_device *vfe, u8 enable) in vfe_set_module_cfg() argument
1013 if (enable) { in vfe_set_module_cfg()
1027 ret = readl_poll_timeout(vfe->base + VFE_0_CAMIF_STATUS, in vfe_camif_wait_for_stop()
1041 * vfe_isr - VFE module interrupt handler
1053 vfe->ops->isr_read(vfe, &value0, &value1); in vfe_isr()
1055 dev_dbg(vfe->camss->dev, "VFE: status0 = 0x%08x, status1 = 0x%08x\n", in vfe_isr()
1059 vfe->isr_ops.reset_ack(vfe); in vfe_isr()
1062 vfe->ops->violation_read(vfe); in vfe_isr()
1065 vfe->isr_ops.halt_ack(vfe); in vfe_isr()
1067 for (i = VFE_LINE_RDI0; i < vfe->line_num; i++) in vfe_isr()
1069 vfe->isr_ops.reg_update(vfe, i); in vfe_isr()
1072 vfe->isr_ops.sof(vfe, VFE_LINE_PIX); in vfe_isr()
1076 vfe->isr_ops.sof(vfe, i); in vfe_isr()
1080 vfe->isr_ops.comp_done(vfe, i); in vfe_isr()
1081 for (j = 0; j < ARRAY_SIZE(vfe->wm_output_map); j++) in vfe_isr()
1082 if (vfe->wm_output_map[j] == VFE_LINE_PIX) in vfe_isr()
1088 vfe->isr_ops.wm_done(vfe, i); in vfe_isr()
1095 *value0 = readl_relaxed(vfe->base + VFE_0_IRQ_STATUS_0); in vfe_isr_read()
1096 *value1 = readl_relaxed(vfe->base + VFE_0_IRQ_STATUS_1); in vfe_isr_read()
1098 writel_relaxed(*value0, vfe->base + VFE_0_IRQ_CLEAR_0); in vfe_isr_read()
1099 writel_relaxed(*value1, vfe->base + VFE_0_IRQ_CLEAR_1); in vfe_isr_read()
1103 writel_relaxed(VFE_0_IRQ_CMD_GLOBAL_CLEAR, vfe->base + VFE_0_IRQ_CMD); in vfe_isr_read()
1108 u32 violation = readl_relaxed(vfe->base + VFE_0_VIOLATION_STATUS); in vfe_violation_read()
1152 vfe->isr_ops = vfe_isr_ops_gen1; in vfe_subdev_init()
1153 vfe->ops_gen1 = &vfe_ops_gen1_4_7; in vfe_subdev_init()
1154 vfe->video_ops = vfe_video_ops_gen1; in vfe_subdev_init()