linux/drivers/media/platform/qcom/camss/camss-ispif.c

// SPDX-License-Identifier: GPL-2.0
/*
 * camss-ispif.c
 *
 * Qualcomm MSM Camera Subsystem - ISPIF (ISP Interface) Module
 *
 * Copyright (c) 2013-2015, The Linux Foundation. All rights reserved.
 * Copyright (C) 2015-2018 Linaro Ltd.
 */
#include <linux/clk.h>
#include <linux/completion.h>
#include <linux/interrupt.h>
#include <linux/io.h>
#include <linux/iopoll.h>
#include <linux/kernel.h>
#include <linux/mutex.h>
#include <linux/platform_device.h>
#include <linux/pm_runtime.h>
#include <media/media-entity.h>
#include <media/v4l2-device.h>
#include <media/v4l2-subdev.h>

#include "camss-ispif.h"
#include "camss.h"

#define MSM_ISPIF_NAME

#define ISPIF_RST_CMD_0
#define ISPIF_RST_CMD_1
#define ISPIF_RST_CMD_0_STROBED_RST_EN
#define ISPIF_RST_CMD_0_MISC_LOGIC_RST
#define ISPIF_RST_CMD_0_SW_REG_RST
#define ISPIF_RST_CMD_0_PIX_INTF_0_CSID_RST
#define ISPIF_RST_CMD_0_PIX_INTF_0_VFE_RST
#define ISPIF_RST_CMD_0_PIX_INTF_1_CSID_RST
#define ISPIF_RST_CMD_0_PIX_INTF_1_VFE_RST
#define ISPIF_RST_CMD_0_RDI_INTF_0_CSID_RST
#define ISPIF_RST_CMD_0_RDI_INTF_0_VFE_RST
#define ISPIF_RST_CMD_0_RDI_INTF_1_CSID_RST
#define ISPIF_RST_CMD_0_RDI_INTF_1_VFE_RST
#define ISPIF_RST_CMD_0_RDI_INTF_2_CSID_RST
#define ISPIF_RST_CMD_0_RDI_INTF_2_VFE_RST
#define ISPIF_RST_CMD_0_PIX_OUTPUT_0_MISR_RST
#define ISPIF_RST_CMD_0_RDI_OUTPUT_0_MISR_RST
#define ISPIF_RST_CMD_0_RDI_OUTPUT_1_MISR_RST
#define ISPIF_RST_CMD_0_RDI_OUTPUT_2_MISR_RST
#define ISPIF_IRQ_GLOBAL_CLEAR_CMD
#define ISPIF_VFE_m_CTRL_0(m)
#define ISPIF_VFE_m_CTRL_0_PIX0_LINE_BUF_EN
#define ISPIF_VFE_m_IRQ_MASK_0(m)
#define ISPIF_VFE_m_IRQ_MASK_0_PIX0_ENABLE
#define ISPIF_VFE_m_IRQ_MASK_0_PIX0_MASK
#define ISPIF_VFE_m_IRQ_MASK_0_RDI0_ENABLE
#define ISPIF_VFE_m_IRQ_MASK_0_RDI0_MASK
#define ISPIF_VFE_m_IRQ_MASK_1(m)
#define ISPIF_VFE_m_IRQ_MASK_1_PIX1_ENABLE
#define ISPIF_VFE_m_IRQ_MASK_1_PIX1_MASK
#define ISPIF_VFE_m_IRQ_MASK_1_RDI1_ENABLE
#define ISPIF_VFE_m_IRQ_MASK_1_RDI1_MASK
#define ISPIF_VFE_m_IRQ_MASK_2(m)
#define ISPIF_VFE_m_IRQ_MASK_2_RDI2_ENABLE
#define ISPIF_VFE_m_IRQ_MASK_2_RDI2_MASK
#define ISPIF_VFE_m_IRQ_STATUS_0(m)
#define ISPIF_VFE_m_IRQ_STATUS_0_PIX0_OVERFLOW
#define ISPIF_VFE_m_IRQ_STATUS_0_RDI0_OVERFLOW
#define ISPIF_VFE_m_IRQ_STATUS_1(m)
#define ISPIF_VFE_m_IRQ_STATUS_1_PIX1_OVERFLOW
#define ISPIF_VFE_m_IRQ_STATUS_1_RDI1_OVERFLOW
#define ISPIF_VFE_m_IRQ_STATUS_2(m)
#define ISPIF_VFE_m_IRQ_STATUS_2_RDI2_OVERFLOW
#define ISPIF_VFE_m_IRQ_CLEAR_0(m)
#define ISPIF_VFE_m_IRQ_CLEAR_1(m)
#define ISPIF_VFE_m_IRQ_CLEAR_2(m)
#define ISPIF_VFE_m_INTF_INPUT_SEL(m)
#define ISPIF_VFE_m_INTF_CMD_0(m)
#define ISPIF_VFE_m_INTF_CMD_1(m)
#define ISPIF_VFE_m_PIX_INTF_n_CID_MASK(m, n)
#define ISPIF_VFE_m_RDI_INTF_n_CID_MASK(m, n)
/* PACK_CFG registers are 8x96 only */
#define ISPIF_VFE_m_RDI_INTF_n_PACK_CFG_0(m, n)
#define ISPIF_VFE_m_RDI_INTF_n_PACK_CFG_1(m, n)
#define ISPIF_VFE_m_RDI_INTF_n_PACK_CFG_0_CID_c_PLAIN(c)
#define ISPIF_VFE_m_PIX_INTF_n_STATUS(m, n)
#define ISPIF_VFE_m_RDI_INTF_n_STATUS(m, n)

#define CSI_PIX_CLK_MUX_SEL
#define CSI_RDI_CLK_MUX_SEL

#define ISPIF_TIMEOUT_SLEEP_US
#define ISPIF_TIMEOUT_ALL_US
#define ISPIF_RESET_TIMEOUT_MS

enum ispif_intf_cmd {};

static const u32 ispif_formats_8x16[] =;

static const u32 ispif_formats_8x96[] =;

/*
 * ispif_isr_8x96 - ISPIF module interrupt handler for 8x96
 * @irq: Interrupt line
 * @dev: ISPIF device
 *
 * Return IRQ_HANDLED on success
 */
static irqreturn_t ispif_isr_8x96(int irq, void *dev)
{}

/*
 * ispif_isr_8x16 - ISPIF module interrupt handler for 8x16
 * @irq: Interrupt line
 * @dev: ISPIF device
 *
 * Return IRQ_HANDLED on success
 */
static irqreturn_t ispif_isr_8x16(int irq, void *dev)
{}

static int ispif_vfe_reset(struct ispif_device *ispif, u8 vfe_id)
{}

/*
 * ispif_reset - Trigger reset on ISPIF module and wait to complete
 * @ispif: ISPIF device
 *
 * Return 0 on success or a negative error code otherwise
 */
static int ispif_reset(struct ispif_device *ispif, u8 vfe_id)
{}

/*
 * ispif_set_power - Power on/off ISPIF module
 * @sd: ISPIF V4L2 subdevice
 * @on: Requested power state
 *
 * Return 0 on success or a negative error code otherwise
 */
static int ispif_set_power(struct v4l2_subdev *sd, int on)
{}

/*
 * ispif_select_clk_mux - Select clock for PIX/RDI interface
 * @ispif: ISPIF device
 * @intf: VFE interface
 * @csid: CSID HW module id
 * @vfe: VFE HW module id
 * @enable: enable or disable the selected clock
 */
static void ispif_select_clk_mux(struct ispif_device *ispif,
				 enum ispif_intf intf, u8 csid,
				 u8 vfe, u8 enable)
{}

/*
 * ispif_validate_intf_status - Validate current status of PIX/RDI interface
 * @ispif: ISPIF device
 * @intf: VFE interface
 * @vfe: VFE HW module id
 *
 * Return 0 when interface is idle or -EBUSY otherwise
 */
static int ispif_validate_intf_status(struct ispif_device *ispif,
				      enum ispif_intf intf, u8 vfe)
{}

/*
 * ispif_wait_for_stop - Wait for PIX/RDI interface to stop
 * @ispif: ISPIF device
 * @intf: VFE interface
 * @vfe: VFE HW module id
 *
 * Return 0 on success or a negative error code otherwise
 */
static int ispif_wait_for_stop(struct ispif_device *ispif,
			       enum ispif_intf intf, u8 vfe)
{}

/*
 * ispif_select_csid - Select CSID HW module for input from
 * @ispif: ISPIF device
 * @intf: VFE interface
 * @csid: CSID HW module id
 * @vfe: VFE HW module id
 * @enable: enable or disable the selected input
 */
static void ispif_select_csid(struct ispif_device *ispif, enum ispif_intf intf,
			      u8 csid, u8 vfe, u8 enable)
{}

/*
 * ispif_select_cid - Enable/disable desired CID
 * @ispif: ISPIF device
 * @intf: VFE interface
 * @cid: desired CID to enable/disable
 * @vfe: VFE HW module id
 * @enable: enable or disable the desired CID
 */
static void ispif_select_cid(struct ispif_device *ispif, enum ispif_intf intf,
			     u8 cid, u8 vfe, u8 enable)
{}

/*
 * ispif_config_irq - Enable/disable interrupts for PIX/RDI interface
 * @ispif: ISPIF device
 * @intf: VFE interface
 * @vfe: VFE HW module id
 * @enable: enable or disable
 */
static void ispif_config_irq(struct ispif_device *ispif, enum ispif_intf intf,
			     u8 vfe, u8 enable)
{}

/*
 * ispif_config_pack - Config packing for PRDI mode
 * @ispif: ISPIF device
 * @code: media bus format code
 * @intf: VFE interface
 * @cid: desired CID to handle
 * @vfe: VFE HW module id
 * @enable: enable or disable
 */
static void ispif_config_pack(struct ispif_device *ispif, u32 code,
			      enum ispif_intf intf, u8 cid, u8 vfe, u8 enable)
{}

/*
 * ispif_set_intf_cmd - Set command to enable/disable interface
 * @ispif: ISPIF device
 * @cmd: interface command
 * @intf: VFE interface
 * @vfe: VFE HW module id
 * @vc: virtual channel
 */
static void ispif_set_intf_cmd(struct ispif_device *ispif, u8 cmd,
			       enum ispif_intf intf, u8 vfe, u8 vc)
{}

/*
 * ispif_set_stream - Enable/disable streaming on ISPIF module
 * @sd: ISPIF V4L2 subdevice
 * @enable: Requested streaming state
 *
 * Main configuration of ISPIF module is also done here.
 *
 * Return 0 on success or a negative error code otherwise
 */
static int ispif_set_stream(struct v4l2_subdev *sd, int enable)
{}

/*
 * __ispif_get_format - Get pointer to format structure
 * @ispif: ISPIF line
 * @sd_state: V4L2 subdev state
 * @pad: pad from which format is requested
 * @which: TRY or ACTIVE format
 *
 * Return pointer to TRY or ACTIVE format structure
 */
static struct v4l2_mbus_framefmt *
__ispif_get_format(struct ispif_line *line,
		   struct v4l2_subdev_state *sd_state,
		   unsigned int pad,
		   enum v4l2_subdev_format_whence which)
{}

/*
 * ispif_try_format - Handle try format by pad subdev method
 * @ispif: ISPIF line
 * @sd_state: V4L2 subdev state
 * @pad: pad on which format is requested
 * @fmt: pointer to v4l2 format structure
 * @which: wanted subdev format
 */
static void ispif_try_format(struct ispif_line *line,
			     struct v4l2_subdev_state *sd_state,
			     unsigned int pad,
			     struct v4l2_mbus_framefmt *fmt,
			     enum v4l2_subdev_format_whence which)
{}

/*
 * ispif_enum_mbus_code - Handle pixel format enumeration
 * @sd: ISPIF V4L2 subdevice
 * @sd_state: V4L2 subdev state
 * @code: pointer to v4l2_subdev_mbus_code_enum structure
 * return -EINVAL or zero on success
 */
static int ispif_enum_mbus_code(struct v4l2_subdev *sd,
				struct v4l2_subdev_state *sd_state,
				struct v4l2_subdev_mbus_code_enum *code)
{}

/*
 * ispif_enum_frame_size - Handle frame size enumeration
 * @sd: ISPIF V4L2 subdevice
 * @sd_state: V4L2 subdev state
 * @fse: pointer to v4l2_subdev_frame_size_enum structure
 * return -EINVAL or zero on success
 */
static int ispif_enum_frame_size(struct v4l2_subdev *sd,
				 struct v4l2_subdev_state *sd_state,
				 struct v4l2_subdev_frame_size_enum *fse)
{}

/*
 * ispif_get_format - Handle get format by pads subdev method
 * @sd: ISPIF V4L2 subdevice
 * @sd_state: V4L2 subdev state
 * @fmt: pointer to v4l2 subdev format structure
 *
 * Return -EINVAL or zero on success
 */
static int ispif_get_format(struct v4l2_subdev *sd,
			    struct v4l2_subdev_state *sd_state,
			    struct v4l2_subdev_format *fmt)
{}

/*
 * ispif_set_format - Handle set format by pads subdev method
 * @sd: ISPIF V4L2 subdevice
 * @sd_state: V4L2 subdev state
 * @fmt: pointer to v4l2 subdev format structure
 *
 * Return -EINVAL or zero on success
 */
static int ispif_set_format(struct v4l2_subdev *sd,
			    struct v4l2_subdev_state *sd_state,
			    struct v4l2_subdev_format *fmt)
{}

/*
 * ispif_init_formats - Initialize formats on all pads
 * @sd: ISPIF V4L2 subdevice
 * @fh: V4L2 subdev file handle
 *
 * Initialize all pad formats with default values.
 *
 * Return 0 on success or a negative error code otherwise
 */
static int ispif_init_formats(struct v4l2_subdev *sd, struct v4l2_subdev_fh *fh)
{}

/*
 * msm_ispif_subdev_init - Initialize ISPIF device structure and resources
 * @ispif: ISPIF device
 * @res: ISPIF module resources table
 *
 * Return 0 on success or a negative error code otherwise
 */
int msm_ispif_subdev_init(struct camss *camss,
			  const struct camss_subdev_resources *res)
{}

/*
 * ispif_get_intf - Get ISPIF interface to use by VFE line id
 * @line_id: VFE line id that the ISPIF line is connected to
 *
 * Return ISPIF interface to use
 */
static enum ispif_intf ispif_get_intf(enum vfe_line_id line_id)
{}

/*
 * ispif_get_vfe_id - Get VFE HW module id
 * @entity: Pointer to VFE media entity structure
 * @id: Return CSID HW module id here
 */
static void ispif_get_vfe_id(struct media_entity *entity, u8 *id)
{}

/*
 * ispif_get_vfe_line_id - Get VFE line id by media entity
 * @entity: Pointer to VFE media entity structure
 * @id: Return VFE line id here
 */
static void ispif_get_vfe_line_id(struct media_entity *entity,
				  enum vfe_line_id *id)
{}

/*
 * ispif_link_setup - Setup ISPIF connections
 * @entity: Pointer to media entity structure
 * @local: Pointer to local pad
 * @remote: Pointer to remote pad
 * @flags: Link flags
 *
 * Return 0 on success
 */
static int ispif_link_setup(struct media_entity *entity,
			    const struct media_pad *local,
			    const struct media_pad *remote, u32 flags)
{}

static const struct v4l2_subdev_core_ops ispif_core_ops =;

static const struct v4l2_subdev_video_ops ispif_video_ops =;

static const struct v4l2_subdev_pad_ops ispif_pad_ops =;

static const struct v4l2_subdev_ops ispif_v4l2_ops =;

static const struct v4l2_subdev_internal_ops ispif_v4l2_internal_ops =;

static const struct media_entity_operations ispif_media_ops =;

/*
 * msm_ispif_register_entities - Register subdev node for ISPIF module
 * @ispif: ISPIF device
 * @v4l2_dev: V4L2 device
 *
 * Return 0 on success or a negative error code otherwise
 */
int msm_ispif_register_entities(struct ispif_device *ispif,
				struct v4l2_device *v4l2_dev)
{}

/*
 * msm_ispif_unregister_entities - Unregister ISPIF module subdev node
 * @ispif: ISPIF device
 */
void msm_ispif_unregister_entities(struct ispif_device *ispif)
{}