/* SPDX-License-Identifier: GPL-2.0-or-later */1/*2* Copyright (C) 2011 Freescale Semiconductor, Inc.3*/45#ifndef __DW_HDMI__6#define __DW_HDMI__78#include <sound/hdmi-codec.h>910struct drm_display_info;11struct drm_display_mode;12struct drm_encoder;13struct dw_hdmi;14struct platform_device;1516/**17* DOC: Supported input formats and encodings18*19* Depending on the Hardware configuration of the Controller IP, it supports20* a subset of the following input formats and encodings on its internal21* 48bit bus.22*23* +----------------------+----------------------------------+------------------------------+24* | Format Name | Format Code | Encodings |25* +----------------------+----------------------------------+------------------------------+26* | RGB 4:4:4 8bit | ``MEDIA_BUS_FMT_RGB888_1X24`` | ``V4L2_YCBCR_ENC_DEFAULT`` |27* +----------------------+----------------------------------+------------------------------+28* | RGB 4:4:4 10bits | ``MEDIA_BUS_FMT_RGB101010_1X30`` | ``V4L2_YCBCR_ENC_DEFAULT`` |29* +----------------------+----------------------------------+------------------------------+30* | RGB 4:4:4 12bits | ``MEDIA_BUS_FMT_RGB121212_1X36`` | ``V4L2_YCBCR_ENC_DEFAULT`` |31* +----------------------+----------------------------------+------------------------------+32* | RGB 4:4:4 16bits | ``MEDIA_BUS_FMT_RGB161616_1X48`` | ``V4L2_YCBCR_ENC_DEFAULT`` |33* +----------------------+----------------------------------+------------------------------+34* | YCbCr 4:4:4 8bit | ``MEDIA_BUS_FMT_YUV8_1X24`` | ``V4L2_YCBCR_ENC_601`` |35* | | | or ``V4L2_YCBCR_ENC_709`` |36* | | | or ``V4L2_YCBCR_ENC_XV601`` |37* | | | or ``V4L2_YCBCR_ENC_XV709`` |38* +----------------------+----------------------------------+------------------------------+39* | YCbCr 4:4:4 10bits | ``MEDIA_BUS_FMT_YUV10_1X30`` | ``V4L2_YCBCR_ENC_601`` |40* | | | or ``V4L2_YCBCR_ENC_709`` |41* | | | or ``V4L2_YCBCR_ENC_XV601`` |42* | | | or ``V4L2_YCBCR_ENC_XV709`` |43* +----------------------+----------------------------------+------------------------------+44* | YCbCr 4:4:4 12bits | ``MEDIA_BUS_FMT_YUV12_1X36`` | ``V4L2_YCBCR_ENC_601`` |45* | | | or ``V4L2_YCBCR_ENC_709`` |46* | | | or ``V4L2_YCBCR_ENC_XV601`` |47* | | | or ``V4L2_YCBCR_ENC_XV709`` |48* +----------------------+----------------------------------+------------------------------+49* | YCbCr 4:4:4 16bits | ``MEDIA_BUS_FMT_YUV16_1X48`` | ``V4L2_YCBCR_ENC_601`` |50* | | | or ``V4L2_YCBCR_ENC_709`` |51* | | | or ``V4L2_YCBCR_ENC_XV601`` |52* | | | or ``V4L2_YCBCR_ENC_XV709`` |53* +----------------------+----------------------------------+------------------------------+54* | YCbCr 4:2:2 8bit | ``MEDIA_BUS_FMT_UYVY8_1X16`` | ``V4L2_YCBCR_ENC_601`` |55* | | | or ``V4L2_YCBCR_ENC_709`` |56* +----------------------+----------------------------------+------------------------------+57* | YCbCr 4:2:2 10bits | ``MEDIA_BUS_FMT_UYVY10_1X20`` | ``V4L2_YCBCR_ENC_601`` |58* | | | or ``V4L2_YCBCR_ENC_709`` |59* +----------------------+----------------------------------+------------------------------+60* | YCbCr 4:2:2 12bits | ``MEDIA_BUS_FMT_UYVY12_1X24`` | ``V4L2_YCBCR_ENC_601`` |61* | | | or ``V4L2_YCBCR_ENC_709`` |62* +----------------------+----------------------------------+------------------------------+63* | YCbCr 4:2:0 8bit | ``MEDIA_BUS_FMT_UYYVYY8_0_5X24`` | ``V4L2_YCBCR_ENC_601`` |64* | | | or ``V4L2_YCBCR_ENC_709`` |65* +----------------------+----------------------------------+------------------------------+66* | YCbCr 4:2:0 10bits | ``MEDIA_BUS_FMT_UYYVYY10_0_5X30``| ``V4L2_YCBCR_ENC_601`` |67* | | | or ``V4L2_YCBCR_ENC_709`` |68* +----------------------+----------------------------------+------------------------------+69* | YCbCr 4:2:0 12bits | ``MEDIA_BUS_FMT_UYYVYY12_0_5X36``| ``V4L2_YCBCR_ENC_601`` |70* | | | or ``V4L2_YCBCR_ENC_709`` |71* +----------------------+----------------------------------+------------------------------+72* | YCbCr 4:2:0 16bits | ``MEDIA_BUS_FMT_UYYVYY16_0_5X48``| ``V4L2_YCBCR_ENC_601`` |73* | | | or ``V4L2_YCBCR_ENC_709`` |74* +----------------------+----------------------------------+------------------------------+75*/7677enum {78DW_HDMI_RES_8,79DW_HDMI_RES_10,80DW_HDMI_RES_12,81DW_HDMI_RES_MAX,82};8384enum dw_hdmi_phy_type {85DW_HDMI_PHY_DWC_HDMI_TX_PHY = 0x00,86DW_HDMI_PHY_DWC_MHL_PHY_HEAC = 0xb2,87DW_HDMI_PHY_DWC_MHL_PHY = 0xc2,88DW_HDMI_PHY_DWC_HDMI_3D_TX_PHY_HEAC = 0xe2,89DW_HDMI_PHY_DWC_HDMI_3D_TX_PHY = 0xf2,90DW_HDMI_PHY_DWC_HDMI20_TX_PHY = 0xf3,91DW_HDMI_PHY_VENDOR_PHY = 0xfe,92};9394struct dw_hdmi_mpll_config {95unsigned long mpixelclock;96struct {97u16 cpce;98u16 gmp;99} res[DW_HDMI_RES_MAX];100};101102struct dw_hdmi_curr_ctrl {103unsigned long mpixelclock;104u16 curr[DW_HDMI_RES_MAX];105};106107struct dw_hdmi_phy_config {108unsigned long mpixelclock;109u16 sym_ctr; /*clock symbol and transmitter control*/110u16 term; /*transmission termination value*/111u16 vlev_ctr; /* voltage level control */112};113114struct dw_hdmi_phy_ops {115int (*init)(struct dw_hdmi *hdmi, void *data,116const struct drm_display_info *display,117const struct drm_display_mode *mode);118void (*disable)(struct dw_hdmi *hdmi, void *data);119enum drm_connector_status (*read_hpd)(struct dw_hdmi *hdmi, void *data);120void (*update_hpd)(struct dw_hdmi *hdmi, void *data,121bool force, bool disabled, bool rxsense);122void (*setup_hpd)(struct dw_hdmi *hdmi, void *data);123};124125struct dw_hdmi_plat_data {126struct regmap *regm;127128unsigned int output_port;129130unsigned long input_bus_encoding;131bool use_drm_infoframe;132bool ycbcr_420_allowed;133134/*135* Private data passed to all the .mode_valid() and .configure_phy()136* callback functions.137*/138void *priv_data;139140/* Platform-specific mode validation (optional). */141enum drm_mode_status (*mode_valid)(struct dw_hdmi *hdmi, void *data,142const struct drm_display_info *info,143const struct drm_display_mode *mode);144145/* Platform-specific audio enable/disable (optional) */146void (*enable_audio)(struct dw_hdmi *hdmi, int channel,147int width, int rate, int non_pcm);148void (*disable_audio)(struct dw_hdmi *hdmi);149150/* Vendor PHY support */151const struct dw_hdmi_phy_ops *phy_ops;152const char *phy_name;153void *phy_data;154unsigned int phy_force_vendor;155156/* Synopsys PHY support */157const struct dw_hdmi_mpll_config *mpll_cfg;158const struct dw_hdmi_curr_ctrl *cur_ctr;159const struct dw_hdmi_phy_config *phy_config;160int (*configure_phy)(struct dw_hdmi *hdmi, void *data,161unsigned long mpixelclock);162163unsigned int disable_cec : 1;164};165166struct dw_hdmi *dw_hdmi_probe(struct platform_device *pdev,167const struct dw_hdmi_plat_data *plat_data);168void dw_hdmi_remove(struct dw_hdmi *hdmi);169void dw_hdmi_unbind(struct dw_hdmi *hdmi);170struct dw_hdmi *dw_hdmi_bind(struct platform_device *pdev,171struct drm_encoder *encoder,172const struct dw_hdmi_plat_data *plat_data);173174void dw_hdmi_resume(struct dw_hdmi *hdmi);175176void dw_hdmi_setup_rx_sense(struct dw_hdmi *hdmi, bool hpd, bool rx_sense);177178int dw_hdmi_set_plugged_cb(struct dw_hdmi *hdmi, hdmi_codec_plugged_cb fn,179struct device *codec_dev);180void dw_hdmi_set_sample_non_pcm(struct dw_hdmi *hdmi, unsigned int non_pcm);181void dw_hdmi_set_sample_width(struct dw_hdmi *hdmi, unsigned int width);182void dw_hdmi_set_sample_rate(struct dw_hdmi *hdmi, unsigned int rate);183void dw_hdmi_set_channel_count(struct dw_hdmi *hdmi, unsigned int cnt);184void dw_hdmi_set_channel_status(struct dw_hdmi *hdmi, u8 *channel_status);185void dw_hdmi_set_channel_allocation(struct dw_hdmi *hdmi, unsigned int ca);186void dw_hdmi_audio_enable(struct dw_hdmi *hdmi);187void dw_hdmi_audio_disable(struct dw_hdmi *hdmi);188void dw_hdmi_set_high_tmds_clock_ratio(struct dw_hdmi *hdmi,189const struct drm_display_info *display);190191/* PHY configuration */192void dw_hdmi_phy_i2c_set_addr(struct dw_hdmi *hdmi, u8 address);193void dw_hdmi_phy_i2c_write(struct dw_hdmi *hdmi, unsigned short data,194unsigned char addr);195196void dw_hdmi_phy_gen1_reset(struct dw_hdmi *hdmi);197198void dw_hdmi_phy_gen2_pddq(struct dw_hdmi *hdmi, u8 enable);199void dw_hdmi_phy_gen2_txpwron(struct dw_hdmi *hdmi, u8 enable);200void dw_hdmi_phy_gen2_reset(struct dw_hdmi *hdmi);201202enum drm_connector_status dw_hdmi_phy_read_hpd(struct dw_hdmi *hdmi,203void *data);204void dw_hdmi_phy_update_hpd(struct dw_hdmi *hdmi, void *data,205bool force, bool disabled, bool rxsense);206void dw_hdmi_phy_setup_hpd(struct dw_hdmi *hdmi, void *data);207208bool dw_hdmi_bus_fmt_is_420(struct dw_hdmi *hdmi);209210#endif /* __IMX_HDMI_H__ */211212213