Lines Matching +full:output +full:- +full:enable
1 // SPDX-License-Identifier: GPL-2.0
3 * camss-vfe-4-8.c
5 * Qualcomm MSM Camera Subsystem - VFE (Video Front End) Module v4.8
7 * Copyright (c) 2013-2015, The Linux Foundation. All rights reserved.
8 * Copyright (C) 2015-2021 Linaro Ltd.
17 #include "camss-vfe.h"
18 #include "camss-vfe-gen1.h"
252 u32 hw_version = readl_relaxed(vfe->base + VFE_0_HW_VERSION); in vfe_hw_version()
254 dev_dbg(vfe->camss->dev, "VFE HW Version = 0x%08x\n", hw_version); in vfe_hw_version()
261 u32 bits = readl_relaxed(vfe->base + reg); in vfe_reg_clr()
263 writel_relaxed(bits & ~clr_bits, vfe->base + reg); in vfe_reg_clr()
268 u32 bits = readl_relaxed(vfe->base + reg); in vfe_reg_set()
270 writel_relaxed(bits | set_bits, vfe->base + reg); in vfe_reg_set()
286 writel_relaxed(BIT(31), vfe->base + VFE_0_IRQ_MASK_0); in vfe_global_reset()
290 writel_relaxed(reset_bits, vfe->base + VFE_0_GLOBAL_RESET_CMD); in vfe_global_reset()
296 vfe->base + VFE_0_BUS_BDG_CMD); in vfe_halt_request()
301 writel_relaxed(0x0, vfe->base + VFE_0_BUS_BDG_CMD); in vfe_halt_clear()
304 static void vfe_wm_frame_based(struct vfe_device *vfe, u8 wm, u8 enable) in vfe_wm_frame_based() argument
306 if (enable) in vfe_wm_frame_based()
314 #define CALC_WORD(width, M, N) (((width) * (M) + (N) - 1) / (N))
346 *width = pix->width; in vfe_get_wm_sizes()
347 *height = pix->height; in vfe_get_wm_sizes()
349 switch (pix->pixelformat) { in vfe_get_wm_sizes()
352 *bytesperline = pix->plane_fmt[0].bytesperline; in vfe_get_wm_sizes()
358 *bytesperline = pix->plane_fmt[0].bytesperline; in vfe_get_wm_sizes()
364 *bytesperline = pix->plane_fmt[plane].bytesperline; in vfe_get_wm_sizes()
371 u8 plane, u32 enable) in vfe_wm_line_based() argument
375 if (enable) { in vfe_wm_line_based()
380 wpl = vfe_word_per_line_by_pixel(pix->pixelformat, width); in vfe_wm_line_based()
382 reg = height - 1; in vfe_wm_line_based()
383 reg |= ((wpl + 3) / 4 - 1) << 16; in vfe_wm_line_based()
385 writel_relaxed(reg, vfe->base + in vfe_wm_line_based()
391 reg |= (height - 1) << 2; in vfe_wm_line_based()
394 writel_relaxed(reg, vfe->base + in vfe_wm_line_based()
397 writel_relaxed(0, vfe->base + in vfe_wm_line_based()
399 writel_relaxed(0, vfe->base + in vfe_wm_line_based()
408 reg = readl_relaxed(vfe->base + in vfe_wm_set_framedrop_period()
417 vfe->base + VFE_0_BUS_IMAGE_MASTER_n_WR_ADDR_CFG(wm)); in vfe_wm_set_framedrop_period()
423 writel_relaxed(pattern, vfe->base + VFE_0_BUS_IMAGE_MASTER_n_WR_FRAMEDROP_PATTERN(wm)); in vfe_wm_set_framedrop_pattern()
433 writel_relaxed(reg, vfe->base + VFE_0_BUS_IMAGE_MASTER_n_WR_UB_CFG(wm)); in vfe_wm_set_ub_cfg()
441 writel_relaxed(VFE_0_BUS_CMD_Mx_RLD_CMD(wm), vfe->base + VFE_0_BUS_CMD); in vfe_bus_reload_wm()
450 vfe->base + VFE_0_BUS_IMAGE_MASTER_n_WR_PING_ADDR(wm)); in vfe_wm_set_ping_addr()
456 vfe->base + VFE_0_BUS_IMAGE_MASTER_n_WR_PONG_ADDR(wm)); in vfe_wm_set_pong_addr()
463 reg = readl_relaxed(vfe->base + VFE_0_BUS_PING_PONG_STATUS); in vfe_wm_get_ping_pong_status()
468 static void vfe_bus_enable_wr_if(struct vfe_device *vfe, u8 enable) in vfe_bus_enable_wr_if() argument
470 if (enable) in vfe_bus_enable_wr_if()
471 writel_relaxed(0x101, vfe->base + VFE_0_BUS_CFG); in vfe_bus_enable_wr_if()
473 writel_relaxed(0, vfe->base + VFE_0_BUS_CFG); in vfe_bus_enable_wr_if()
514 vfe->base + VFE_0_BUS_IMAGE_MASTER_n_WR_IRQ_SUBSAMPLE_PATTERN(wm)); in vfe_wm_set_subsample()
547 static void vfe_set_xbar_cfg(struct vfe_device *vfe, struct vfe_output *output, in vfe_set_xbar_cfg() argument
548 u8 enable) in vfe_set_xbar_cfg() argument
550 struct vfe_line *line = container_of(output, struct vfe_line, output); in vfe_set_xbar_cfg()
551 u32 p = line->video_out.active_fmt.fmt.pix_mp.pixelformat; in vfe_set_xbar_cfg()
562 if (output->wm_idx[0] % 2 == 1) in vfe_set_xbar_cfg()
565 if (enable) in vfe_set_xbar_cfg()
567 VFE_0_BUS_XBAR_CFG_x(output->wm_idx[0]), in vfe_set_xbar_cfg()
571 VFE_0_BUS_XBAR_CFG_x(output->wm_idx[0]), in vfe_set_xbar_cfg()
578 if (output->wm_idx[1] % 2 == 1) in vfe_set_xbar_cfg()
581 if (enable) in vfe_set_xbar_cfg()
583 VFE_0_BUS_XBAR_CFG_x(output->wm_idx[1]), in vfe_set_xbar_cfg()
587 VFE_0_BUS_XBAR_CFG_x(output->wm_idx[1]), in vfe_set_xbar_cfg()
600 if (output->wm_idx[0] % 2 == 1) in vfe_set_xbar_cfg()
603 if (enable) in vfe_set_xbar_cfg()
605 VFE_0_BUS_XBAR_CFG_x(output->wm_idx[0]), in vfe_set_xbar_cfg()
609 VFE_0_BUS_XBAR_CFG_x(output->wm_idx[0]), in vfe_set_xbar_cfg()
618 u8 enable) in vfe_set_realign_cfg() argument
620 u32 p = line->video_out.active_fmt.fmt.pix_mp.pixelformat; in vfe_set_realign_cfg()
627 if (enable) { in vfe_set_realign_cfg()
641 writel_relaxed(val, vfe->base + VFE_0_REALIGN_BUF_CFG); in vfe_set_realign_cfg()
655 vfe->reg_update |= VFE_0_REG_UPDATE_line_n(line_id); in vfe_reg_update()
660 writel_relaxed(vfe->reg_update, vfe->base + VFE_0_REG_UPDATE); in vfe_reg_update()
669 vfe->reg_update &= ~VFE_0_REG_UPDATE_line_n(line_id); in vfe_reg_update_clear()
673 enum vfe_line_id line_id, u8 enable) in vfe_enable_irq_wm_line() argument
680 if (enable) { in vfe_enable_irq_wm_line()
690 enum vfe_line_id line_id, u8 enable) in vfe_enable_irq_pix_line() argument
692 struct vfe_output *output = &vfe->line[line_id].output; in vfe_enable_irq_pix_line() local
703 for (i = 0; i < output->wm_num; i++) { in vfe_enable_irq_pix_line()
704 irq_en1 |= VFE_0_IRQ_MASK_1_IMAGE_MASTER_n_BUS_OVERFLOW(output->wm_idx[i]); in vfe_enable_irq_pix_line()
705 comp_mask |= (1 << output->wm_idx[i]) << comp * 8; in vfe_enable_irq_pix_line()
708 if (enable) { in vfe_enable_irq_pix_line()
733 writel_relaxed(VFE_0_DEMUX_CFG_PERIOD, vfe->base + VFE_0_DEMUX_CFG); in vfe_set_demux_cfg()
736 writel_relaxed(val, vfe->base + VFE_0_DEMUX_GAIN_0); in vfe_set_demux_cfg()
739 writel_relaxed(val, vfe->base + VFE_0_DEMUX_GAIN_1); in vfe_set_demux_cfg()
741 switch (line->fmt[MSM_VFE_PAD_SINK].code) { in vfe_set_demux_cfg()
761 writel_relaxed(even_cfg, vfe->base + VFE_0_DEMUX_EVEN_CFG); in vfe_set_demux_cfg()
762 writel_relaxed(odd_cfg, vfe->base + VFE_0_DEMUX_ODD_CFG); in vfe_set_demux_cfg()
767 u32 p = line->video_out.active_fmt.fmt.pix_mp.pixelformat; in vfe_set_scale_cfg()
769 u16 input, output; in vfe_set_scale_cfg() local
773 writel_relaxed(0x3, vfe->base + VFE_0_SCALE_ENC_Y_CFG); in vfe_set_scale_cfg()
775 input = line->fmt[MSM_VFE_PAD_SINK].width - 1; in vfe_set_scale_cfg()
776 output = line->compose.width - 1; in vfe_set_scale_cfg()
777 reg = (output << 16) | input; in vfe_set_scale_cfg()
778 writel_relaxed(reg, vfe->base + VFE_0_SCALE_ENC_Y_H_IMAGE_SIZE); in vfe_set_scale_cfg()
780 interp_reso = vfe_calc_interp_reso(input, output); in vfe_set_scale_cfg()
781 phase_mult = input * (1 << (14 + interp_reso)) / output; in vfe_set_scale_cfg()
783 writel_relaxed(reg, vfe->base + VFE_0_SCALE_ENC_Y_H_PHASE); in vfe_set_scale_cfg()
785 input = line->fmt[MSM_VFE_PAD_SINK].height - 1; in vfe_set_scale_cfg()
786 output = line->compose.height - 1; in vfe_set_scale_cfg()
787 reg = (output << 16) | input; in vfe_set_scale_cfg()
788 writel_relaxed(reg, vfe->base + VFE_0_SCALE_ENC_Y_V_IMAGE_SIZE); in vfe_set_scale_cfg()
790 interp_reso = vfe_calc_interp_reso(input, output); in vfe_set_scale_cfg()
791 phase_mult = input * (1 << (14 + interp_reso)) / output; in vfe_set_scale_cfg()
793 writel_relaxed(reg, vfe->base + VFE_0_SCALE_ENC_Y_V_PHASE); in vfe_set_scale_cfg()
795 writel_relaxed(0x3, vfe->base + VFE_0_SCALE_ENC_CBCR_CFG); in vfe_set_scale_cfg()
797 input = line->fmt[MSM_VFE_PAD_SINK].width - 1; in vfe_set_scale_cfg()
798 output = line->compose.width / 2 - 1; in vfe_set_scale_cfg()
799 reg = (output << 16) | input; in vfe_set_scale_cfg()
800 writel_relaxed(reg, vfe->base + VFE_0_SCALE_ENC_CBCR_H_IMAGE_SIZE); in vfe_set_scale_cfg()
802 interp_reso = vfe_calc_interp_reso(input, output); in vfe_set_scale_cfg()
803 phase_mult = input * (1 << (14 + interp_reso)) / output; in vfe_set_scale_cfg()
805 writel_relaxed(reg, vfe->base + VFE_0_SCALE_ENC_CBCR_H_PHASE); in vfe_set_scale_cfg()
807 input = line->fmt[MSM_VFE_PAD_SINK].height - 1; in vfe_set_scale_cfg()
808 output = line->compose.height - 1; in vfe_set_scale_cfg()
810 output = line->compose.height / 2 - 1; in vfe_set_scale_cfg()
811 reg = (output << 16) | input; in vfe_set_scale_cfg()
812 writel_relaxed(reg, vfe->base + VFE_0_SCALE_ENC_CBCR_V_IMAGE_SIZE); in vfe_set_scale_cfg()
814 interp_reso = vfe_calc_interp_reso(input, output); in vfe_set_scale_cfg()
815 phase_mult = input * (1 << (14 + interp_reso)) / output; in vfe_set_scale_cfg()
817 writel_relaxed(reg, vfe->base + VFE_0_SCALE_ENC_CBCR_V_PHASE); in vfe_set_scale_cfg()
822 u32 p = line->video_out.active_fmt.fmt.pix_mp.pixelformat; in vfe_set_crop_cfg()
826 first = line->crop.left; in vfe_set_crop_cfg()
827 last = line->crop.left + line->crop.width - 1; in vfe_set_crop_cfg()
829 writel_relaxed(reg, vfe->base + VFE_0_CROP_ENC_Y_WIDTH); in vfe_set_crop_cfg()
831 first = line->crop.top; in vfe_set_crop_cfg()
832 last = line->crop.top + line->crop.height - 1; in vfe_set_crop_cfg()
834 writel_relaxed(reg, vfe->base + VFE_0_CROP_ENC_Y_HEIGHT); in vfe_set_crop_cfg()
836 first = line->crop.left / 2; in vfe_set_crop_cfg()
837 last = line->crop.left / 2 + line->crop.width / 2 - 1; in vfe_set_crop_cfg()
839 writel_relaxed(reg, vfe->base + VFE_0_CROP_ENC_CBCR_WIDTH); in vfe_set_crop_cfg()
841 first = line->crop.top; in vfe_set_crop_cfg()
842 last = line->crop.top + line->crop.height - 1; in vfe_set_crop_cfg()
844 first = line->crop.top / 2; in vfe_set_crop_cfg()
845 last = line->crop.top / 2 + line->crop.height / 2 - 1; in vfe_set_crop_cfg()
848 writel_relaxed(reg, vfe->base + VFE_0_CROP_ENC_CBCR_HEIGHT); in vfe_set_crop_cfg()
857 writel_relaxed(val, vfe->base + VFE_0_CLAMP_ENC_MAX_CFG); in vfe_set_clamp_cfg()
863 writel_relaxed(val, vfe->base + VFE_0_CLAMP_ENC_MIN_CFG); in vfe_set_clamp_cfg()
866 static void vfe_set_cgc_override(struct vfe_device *vfe, u8 wm, u8 enable) in vfe_set_cgc_override() argument
875 switch (line->fmt[MSM_VFE_PAD_SINK].code) { in vfe_set_camif_cfg()
892 writel_relaxed(val, vfe->base + VFE_0_CORE_CFG); in vfe_set_camif_cfg()
894 val = line->fmt[MSM_VFE_PAD_SINK].width * 2 - 1; in vfe_set_camif_cfg()
895 val |= (line->fmt[MSM_VFE_PAD_SINK].height - 1) << 16; in vfe_set_camif_cfg()
896 writel_relaxed(val, vfe->base + VFE_0_CAMIF_FRAME_CFG); in vfe_set_camif_cfg()
898 val = line->fmt[MSM_VFE_PAD_SINK].width * 2 - 1; in vfe_set_camif_cfg()
899 writel_relaxed(val, vfe->base + VFE_0_CAMIF_WINDOW_WIDTH_CFG); in vfe_set_camif_cfg()
901 val = line->fmt[MSM_VFE_PAD_SINK].height - 1; in vfe_set_camif_cfg()
902 writel_relaxed(val, vfe->base + VFE_0_CAMIF_WINDOW_HEIGHT_CFG); in vfe_set_camif_cfg()
905 writel_relaxed(val, vfe->base + VFE_0_CAMIF_SUBSAMPLE_CFG); in vfe_set_camif_cfg()
908 writel_relaxed(val, vfe->base + VFE_0_CAMIF_IRQ_FRAMEDROP_PATTERN); in vfe_set_camif_cfg()
911 writel_relaxed(val, vfe->base + VFE_0_CAMIF_IRQ_SUBSAMPLE_PATTERN); in vfe_set_camif_cfg()
917 writel_relaxed(val, vfe->base + VFE_0_CAMIF_CFG); in vfe_set_camif_cfg()
920 static void vfe_set_camif_cmd(struct vfe_device *vfe, u8 enable) in vfe_set_camif_cmd() argument
925 writel_relaxed(cmd, vfe->base + VFE_0_CAMIF_CMD); in vfe_set_camif_cmd()
930 if (enable) in vfe_set_camif_cmd()
935 writel_relaxed(cmd, vfe->base + VFE_0_CAMIF_CMD); in vfe_set_camif_cmd()
938 static void vfe_set_module_cfg(struct vfe_device *vfe, u8 enable) in vfe_set_module_cfg() argument
945 if (enable) { in vfe_set_module_cfg()
959 ret = readl_poll_timeout(vfe->base + VFE_0_CAMIF_STATUS, in vfe_camif_wait_for_stop()
971 * vfe_isr - VFE module interrupt handler
983 vfe->res->hw_ops->isr_read(vfe, &value0, &value1); in vfe_isr()
985 dev_dbg(vfe->camss->dev, "VFE: status0 = 0x%08x, status1 = 0x%08x\n", in vfe_isr()
989 vfe->isr_ops.reset_ack(vfe); in vfe_isr()
992 vfe->res->hw_ops->violation_read(vfe); in vfe_isr()
995 vfe->isr_ops.halt_ack(vfe); in vfe_isr()
997 for (i = VFE_LINE_RDI0; i < vfe->res->line_num; i++) in vfe_isr()
999 vfe->isr_ops.reg_update(vfe, i); in vfe_isr()
1002 vfe->isr_ops.sof(vfe, VFE_LINE_PIX); in vfe_isr()
1006 vfe->isr_ops.sof(vfe, i); in vfe_isr()
1010 vfe->isr_ops.comp_done(vfe, i); in vfe_isr()
1011 for (j = 0; j < ARRAY_SIZE(vfe->wm_output_map); j++) in vfe_isr()
1012 if (vfe->wm_output_map[j] == VFE_LINE_PIX) in vfe_isr()
1018 vfe->isr_ops.wm_done(vfe, i); in vfe_isr()
1025 /* On VFE4.8 the ub-size is the same on both instances */ in vfe_get_ub_size()
1029 static void vfe_wm_enable(struct vfe_device *vfe, u8 wm, u8 enable) in vfe_wm_enable() argument
1031 if (enable) in vfe_wm_enable()
1033 vfe->base + VFE_0_BUS_IMAGE_MASTER_CMD); in vfe_wm_enable()
1036 vfe->base + VFE_0_BUS_IMAGE_MASTER_CMD); in vfe_wm_enable()
1049 writel_relaxed(val, vfe->base + VFE_0_BUS_BDG_QOS_CFG_0); in vfe_set_qos()
1050 writel_relaxed(val, vfe->base + VFE_0_BUS_BDG_QOS_CFG_1); in vfe_set_qos()
1051 writel_relaxed(val, vfe->base + VFE_0_BUS_BDG_QOS_CFG_2); in vfe_set_qos()
1052 writel_relaxed(val3, vfe->base + VFE_0_BUS_BDG_QOS_CFG_3); in vfe_set_qos()
1053 writel_relaxed(val4, vfe->base + VFE_0_BUS_BDG_QOS_CFG_4); in vfe_set_qos()
1054 writel_relaxed(val4, vfe->base + VFE_0_BUS_BDG_QOS_CFG_5); in vfe_set_qos()
1055 writel_relaxed(val4, vfe->base + VFE_0_BUS_BDG_QOS_CFG_6); in vfe_set_qos()
1056 writel_relaxed(val7, vfe->base + VFE_0_BUS_BDG_QOS_CFG_7); in vfe_set_qos()
1064 writel_relaxed(val, vfe->base + VFE_0_BUS_BDG_DS_CFG_0); in vfe_set_ds()
1065 writel_relaxed(val, vfe->base + VFE_0_BUS_BDG_DS_CFG_1); in vfe_set_ds()
1066 writel_relaxed(val, vfe->base + VFE_0_BUS_BDG_DS_CFG_2); in vfe_set_ds()
1067 writel_relaxed(val, vfe->base + VFE_0_BUS_BDG_DS_CFG_3); in vfe_set_ds()
1068 writel_relaxed(val, vfe->base + VFE_0_BUS_BDG_DS_CFG_4); in vfe_set_ds()
1069 writel_relaxed(val, vfe->base + VFE_0_BUS_BDG_DS_CFG_5); in vfe_set_ds()
1070 writel_relaxed(val, vfe->base + VFE_0_BUS_BDG_DS_CFG_6); in vfe_set_ds()
1071 writel_relaxed(val, vfe->base + VFE_0_BUS_BDG_DS_CFG_7); in vfe_set_ds()
1072 writel_relaxed(val, vfe->base + VFE_0_BUS_BDG_DS_CFG_8); in vfe_set_ds()
1073 writel_relaxed(val, vfe->base + VFE_0_BUS_BDG_DS_CFG_9); in vfe_set_ds()
1074 writel_relaxed(val, vfe->base + VFE_0_BUS_BDG_DS_CFG_10); in vfe_set_ds()
1075 writel_relaxed(val, vfe->base + VFE_0_BUS_BDG_DS_CFG_11); in vfe_set_ds()
1076 writel_relaxed(val, vfe->base + VFE_0_BUS_BDG_DS_CFG_12); in vfe_set_ds()
1077 writel_relaxed(val, vfe->base + VFE_0_BUS_BDG_DS_CFG_13); in vfe_set_ds()
1078 writel_relaxed(val, vfe->base + VFE_0_BUS_BDG_DS_CFG_14); in vfe_set_ds()
1079 writel_relaxed(val, vfe->base + VFE_0_BUS_BDG_DS_CFG_15); in vfe_set_ds()
1080 writel_relaxed(val16, vfe->base + VFE_0_BUS_BDG_DS_CFG_16); in vfe_set_ds()
1085 *value0 = readl_relaxed(vfe->base + VFE_0_IRQ_STATUS_0); in vfe_isr_read()
1086 *value1 = readl_relaxed(vfe->base + VFE_0_IRQ_STATUS_1); in vfe_isr_read()
1088 writel_relaxed(*value0, vfe->base + VFE_0_IRQ_CLEAR_0); in vfe_isr_read()
1089 writel_relaxed(*value1, vfe->base + VFE_0_IRQ_CLEAR_1); in vfe_isr_read()
1093 writel_relaxed(VFE_0_IRQ_CMD_GLOBAL_CLEAR, vfe->base + VFE_0_IRQ_CMD); in vfe_isr_read()
1098 u32 violation = readl_relaxed(vfe->base + VFE_0_VIOLATION_STATUS); in vfe_violation_read()
1142 vfe->isr_ops = vfe_isr_ops_gen1; in vfe_subdev_init()
1143 vfe->ops_gen1 = &vfe_ops_gen1_4_8; in vfe_subdev_init()
1144 vfe->video_ops = vfe_video_ops_gen1; in vfe_subdev_init()