linux/drivers/gpu/drm/bridge/adv7511/adv7511.h

/* SPDX-License-Identifier: GPL-2.0-only */
/*
 * Analog Devices ADV7511 HDMI transmitter driver
 *
 * Copyright 2012 Analog Devices Inc.
 */

#ifndef __DRM_I2C_ADV7511_H__
#define __DRM_I2C_ADV7511_H__

#include <linux/hdmi.h>
#include <linux/i2c.h>
#include <linux/regmap.h>
#include <linux/regulator/consumer.h>

#include <drm/drm_bridge.h>
#include <drm/drm_connector.h>
#include <drm/drm_mipi_dsi.h>
#include <drm/drm_modes.h>

#define ADV7511_REG_CHIP_REVISION
#define ADV7511_REG_N0
#define ADV7511_REG_N1
#define ADV7511_REG_N2
#define ADV7511_REG_SPDIF_FREQ
#define ADV7511_REG_CTS_AUTOMATIC1
#define ADV7511_REG_CTS_AUTOMATIC2
#define ADV7511_REG_CTS_MANUAL0
#define ADV7511_REG_CTS_MANUAL1
#define ADV7511_REG_CTS_MANUAL2
#define ADV7511_REG_AUDIO_SOURCE
#define ADV7511_REG_AUDIO_CONFIG
#define ADV7511_REG_I2S_CONFIG
#define ADV7511_REG_I2S_WIDTH
#define ADV7511_REG_AUDIO_SUB_SRC0
#define ADV7511_REG_AUDIO_SUB_SRC1
#define ADV7511_REG_AUDIO_SUB_SRC2
#define ADV7511_REG_AUDIO_SUB_SRC3
#define ADV7511_REG_AUDIO_CFG1
#define ADV7511_REG_AUDIO_CFG2
#define ADV7511_REG_AUDIO_CFG3
#define ADV7511_REG_I2C_FREQ_ID_CFG
#define ADV7511_REG_VIDEO_INPUT_CFG1
#define ADV7511_REG_CSC_UPPER(x)
#define ADV7511_REG_CSC_LOWER(x)
#define ADV7511_REG_SYNC_DECODER(x)
#define ADV7511_REG_DE_GENERATOR
#define ADV7511_REG_PIXEL_REPETITION
#define ADV7511_REG_VIC_MANUAL
#define ADV7511_REG_VIC_SEND
#define ADV7511_REG_VIC_DETECTED
#define ADV7511_REG_AUX_VIC_DETECTED
#define ADV7511_REG_PACKET_ENABLE0
#define ADV7511_REG_POWER
#define ADV7511_REG_STATUS
#define ADV7511_REG_EDID_I2C_ADDR
#define ADV7511_REG_PACKET_ENABLE1
#define ADV7511_REG_PACKET_I2C_ADDR
#define ADV7511_REG_DSD_ENABLE
#define ADV7511_REG_VIDEO_INPUT_CFG2
#define ADV7511_REG_INFOFRAME_UPDATE
#define ADV7511_REG_GC(x)
#define ADV7511_REG_AVI_INFOFRAME_VERSION
#define ADV7511_REG_AVI_INFOFRAME_LENGTH
#define ADV7511_REG_AVI_INFOFRAME_CHECKSUM
#define ADV7511_REG_AVI_INFOFRAME(x)
#define ADV7511_REG_AUDIO_INFOFRAME_VERSION
#define ADV7511_REG_AUDIO_INFOFRAME_LENGTH
#define ADV7511_REG_AUDIO_INFOFRAME_CHECKSUM
#define ADV7511_REG_AUDIO_INFOFRAME(x)
#define ADV7511_REG_INT_ENABLE(x)
#define ADV7511_REG_INT(x)
#define ADV7511_REG_INPUT_CLK_DIV
#define ADV7511_REG_PLL_STATUS
#define ADV7511_REG_HDMI_POWER
#define ADV7511_REG_HDCP_HDMI_CFG
#define ADV7511_REG_AN(x)
#define ADV7511_REG_HDCP_STATUS
#define ADV7511_REG_BCAPS
#define ADV7511_REG_BKSV(x)
#define ADV7511_REG_EDID_SEGMENT
#define ADV7511_REG_DDC_STATUS
#define ADV7511_REG_EDID_READ_CTRL
#define ADV7511_REG_BSTATUS(x)
#define ADV7511_REG_TIMING_GEN_SEQ
#define ADV7511_REG_POWER2
#define ADV7511_REG_HSYNC_PLACEMENT_MSB

#define ADV7511_REG_SYNC_ADJUSTMENT(x)
#define ADV7511_REG_TMDS_CLOCK_INV
#define ADV7511_REG_ARC_CTRL
#define ADV7511_REG_CEC_I2C_ADDR
#define ADV7511_REG_CEC_CTRL
#define ADV7511_REG_CHIP_ID_HIGH
#define ADV7511_REG_CHIP_ID_LOW

/* Hardware defined default addresses for I2C register maps */
#define ADV7511_CEC_I2C_ADDR_DEFAULT
#define ADV7511_EDID_I2C_ADDR_DEFAULT
#define ADV7511_PACKET_I2C_ADDR_DEFAULT

#define ADV7511_CSC_ENABLE
#define ADV7511_CSC_UPDATE_MODE

#define ADV7511_INT0_HPD
#define ADV7511_INT0_VSYNC
#define ADV7511_INT0_AUDIO_FIFO_FULL
#define ADV7511_INT0_EDID_READY
#define ADV7511_INT0_HDCP_AUTHENTICATED

#define ADV7511_INT1_DDC_ERROR
#define ADV7511_INT1_BKSV
#define ADV7511_INT1_CEC_TX_READY
#define ADV7511_INT1_CEC_TX_ARBIT_LOST
#define ADV7511_INT1_CEC_TX_RETRY_TIMEOUT
#define ADV7511_INT1_CEC_RX_READY3
#define ADV7511_INT1_CEC_RX_READY2
#define ADV7511_INT1_CEC_RX_READY1

#define ADV7511_ARC_CTRL_POWER_DOWN

#define ADV7511_CEC_CTRL_POWER_DOWN

#define ADV7511_POWER_POWER_DOWN

#define ADV7511_HDMI_CFG_MODE_MASK
#define ADV7511_HDMI_CFG_MODE_DVI
#define ADV7511_HDMI_CFG_MODE_HDMI

#define ADV7511_AUDIO_SELECT_I2C
#define ADV7511_AUDIO_SELECT_SPDIF
#define ADV7511_AUDIO_SELECT_DSD
#define ADV7511_AUDIO_SELECT_HBR
#define ADV7511_AUDIO_SELECT_DST

#define ADV7511_I2S_SAMPLE_LEN_16
#define ADV7511_I2S_SAMPLE_LEN_20
#define ADV7511_I2S_SAMPLE_LEN_18
#define ADV7511_I2S_SAMPLE_LEN_22
#define ADV7511_I2S_SAMPLE_LEN_19
#define ADV7511_I2S_SAMPLE_LEN_23
#define ADV7511_I2S_SAMPLE_LEN_24
#define ADV7511_I2S_SAMPLE_LEN_17
#define ADV7511_I2S_SAMPLE_LEN_21

#define ADV7511_SAMPLE_FREQ_44100
#define ADV7511_SAMPLE_FREQ_48000
#define ADV7511_SAMPLE_FREQ_32000
#define ADV7511_SAMPLE_FREQ_88200
#define ADV7511_SAMPLE_FREQ_96000
#define ADV7511_SAMPLE_FREQ_176400
#define ADV7511_SAMPLE_FREQ_192000

#define ADV7511_STATUS_POWER_DOWN_POLARITY
#define ADV7511_STATUS_HPD
#define ADV7511_STATUS_MONITOR_SENSE
#define ADV7511_STATUS_I2S_32BIT_MODE

#define ADV7511_PACKET_ENABLE_N_CTS
#define ADV7511_PACKET_ENABLE_AUDIO_SAMPLE
#define ADV7511_PACKET_ENABLE_AVI_INFOFRAME
#define ADV7511_PACKET_ENABLE_AUDIO_INFOFRAME
#define ADV7511_PACKET_ENABLE_GC
#define ADV7511_PACKET_ENABLE_SPD
#define ADV7511_PACKET_ENABLE_MPEG
#define ADV7511_PACKET_ENABLE_ACP
#define ADV7511_PACKET_ENABLE_ISRC
#define ADV7511_PACKET_ENABLE_GM
#define ADV7511_PACKET_ENABLE_SPARE2
#define ADV7511_PACKET_ENABLE_SPARE1

#define ADV7535_REG_POWER2_HPD_OVERRIDE
#define ADV7511_REG_POWER2_HPD_SRC_MASK
#define ADV7511_REG_POWER2_HPD_SRC_BOTH
#define ADV7511_REG_POWER2_HPD_SRC_HPD
#define ADV7511_REG_POWER2_HPD_SRC_CEC
#define ADV7511_REG_POWER2_HPD_SRC_NONE
#define ADV7511_REG_POWER2_TDMS_ENABLE
#define ADV7511_REG_POWER2_GATE_INPUT_CLK

#define ADV7511_LOW_REFRESH_RATE_NONE
#define ADV7511_LOW_REFRESH_RATE_24HZ
#define ADV7511_LOW_REFRESH_RATE_25HZ
#define ADV7511_LOW_REFRESH_RATE_30HZ

#define ADV7511_AUDIO_CFG3_LEN_MASK
#define ADV7511_I2C_FREQ_ID_CFG_RATE_MASK

#define ADV7511_AUDIO_SOURCE_I2S
#define ADV7511_AUDIO_SOURCE_SPDIF

#define ADV7511_I2S_FORMAT_I2S
#define ADV7511_I2S_FORMAT_RIGHT_J
#define ADV7511_I2S_FORMAT_LEFT_J
#define ADV7511_I2S_IEC958_DIRECT

#define ADV7511_PACKET(p, x)
#define ADV7511_PACKET_SDP(x)
#define ADV7511_PACKET_MPEG(x)
#define ADV7511_PACKET_ACP(x)
#define ADV7511_PACKET_ISRC1(x)
#define ADV7511_PACKET_ISRC2(x)
#define ADV7511_PACKET_GM(x)
#define ADV7511_PACKET_SPARE(x)

#define ADV7511_REG_CEC_TX_FRAME_HDR
#define ADV7511_REG_CEC_TX_FRAME_DATA0
#define ADV7511_REG_CEC_TX_FRAME_LEN
#define ADV7511_REG_CEC_TX_ENABLE
#define ADV7511_REG_CEC_TX_RETRY
#define ADV7511_REG_CEC_TX_LOW_DRV_CNT
#define ADV7511_REG_CEC_RX1_FRAME_HDR
#define ADV7511_REG_CEC_RX1_FRAME_DATA0
#define ADV7511_REG_CEC_RX1_FRAME_LEN
#define ADV7511_REG_CEC_RX_STATUS
#define ADV7511_REG_CEC_RX2_FRAME_HDR
#define ADV7511_REG_CEC_RX2_FRAME_DATA0
#define ADV7511_REG_CEC_RX2_FRAME_LEN
#define ADV7511_REG_CEC_RX3_FRAME_HDR
#define ADV7511_REG_CEC_RX3_FRAME_DATA0
#define ADV7511_REG_CEC_RX3_FRAME_LEN
#define ADV7511_REG_CEC_RX_BUFFERS
#define ADV7511_REG_CEC_LOG_ADDR_MASK
#define ADV7511_REG_CEC_LOG_ADDR_0_1
#define ADV7511_REG_CEC_LOG_ADDR_2
#define ADV7511_REG_CEC_CLK_DIV
#define ADV7511_REG_CEC_SOFT_RESET

#define ADV7533_REG_CEC_OFFSET

enum adv7511_input_clock {};

enum adv7511_input_justification {};

enum adv7511_input_sync_pulse {};

/**
 * enum adv7511_sync_polarity - Polarity for the input sync signals
 * @ADV7511_SYNC_POLARITY_PASSTHROUGH:  Sync polarity matches that of
 *				       the currently configured mode.
 * @ADV7511_SYNC_POLARITY_LOW:	    Sync polarity is low
 * @ADV7511_SYNC_POLARITY_HIGH:	    Sync polarity is high
 *
 * If the polarity is set to either LOW or HIGH the driver will configure the
 * ADV7511 to internally invert the sync signal if required to match the sync
 * polarity setting for the currently selected output mode.
 *
 * If the polarity is set to PASSTHROUGH, the ADV7511 will route the signal
 * unchanged. This is used when the upstream graphics core already generates
 * the sync signals with the correct polarity.
 */
enum adv7511_sync_polarity {};

/**
 * struct adv7511_link_config - Describes adv7511 hardware configuration
 * @input_color_depth:		Number of bits per color component (8, 10 or 12)
 * @input_colorspace:		The input colorspace (RGB, YUV444, YUV422)
 * @input_clock:		The input video clock style (1x, 2x, DDR)
 * @input_style:		The input component arrangement variant
 * @input_justification:	Video input format bit justification
 * @clock_delay:		Clock delay for the input clock (in ps)
 * @embedded_sync:		Video input uses BT.656-style embedded sync
 * @sync_pulse:			Select the sync pulse
 * @vsync_polarity:		vsync input signal configuration
 * @hsync_polarity:		hsync input signal configuration
 */
struct adv7511_link_config {};

/**
 * enum adv7511_csc_scaling - Scaling factor for the ADV7511 CSC
 * @ADV7511_CSC_SCALING_1: CSC results are not scaled
 * @ADV7511_CSC_SCALING_2: CSC results are scaled by a factor of two
 * @ADV7511_CSC_SCALING_4: CSC results are scalled by a factor of four
 */
enum adv7511_csc_scaling {};

/**
 * struct adv7511_video_config - Describes adv7511 hardware configuration
 * @csc_enable:			Whether to enable color space conversion
 * @csc_scaling_factor:		Color space conversion scaling factor
 * @csc_coefficents:		Color space conversion coefficents
 * @hdmi_mode:			Whether to use HDMI or DVI output mode
 * @avi_infoframe:		HDMI infoframe
 */
struct adv7511_video_config {};

enum adv7511_type {};

#define ADV7511_MAX_ADDRS

struct adv7511_chip_info {};

struct adv7511 {};

#ifdef CONFIG_DRM_I2C_ADV7511_CEC
int adv7511_cec_init(struct device *dev, struct adv7511 *adv7511);
int adv7511_cec_irq_process(struct adv7511 *adv7511, unsigned int irq1);
#else
static inline int adv7511_cec_init(struct device *dev, struct adv7511 *adv7511)
{
	regmap_write(adv7511->regmap, ADV7511_REG_CEC_CTRL,
		     ADV7511_CEC_CTRL_POWER_DOWN);
	return 0;
}
#endif

void adv7533_dsi_power_on(struct adv7511 *adv);
void adv7533_dsi_power_off(struct adv7511 *adv);
enum drm_mode_status adv7533_mode_valid(struct adv7511 *adv,
					const struct drm_display_mode *mode);
int adv7533_patch_registers(struct adv7511 *adv);
int adv7533_patch_cec_registers(struct adv7511 *adv);
int adv7533_attach_dsi(struct adv7511 *adv);
int adv7533_parse_dt(struct device_node *np, struct adv7511 *adv);

#ifdef CONFIG_DRM_I2C_ADV7511_AUDIO
int adv7511_audio_init(struct device *dev, struct adv7511 *adv7511);
void adv7511_audio_exit(struct adv7511 *adv7511);
#else /*CONFIG_DRM_I2C_ADV7511_AUDIO */
static inline int adv7511_audio_init(struct device *dev, struct adv7511 *adv7511)
{
	return 0;
}
static inline void adv7511_audio_exit(struct adv7511 *adv7511)
{
}
#endif /* CONFIG_DRM_I2C_ADV7511_AUDIO */

#endif /* __DRM_I2C_ADV7511_H__ */