blob: dd2a8cf7d20b8d6becb6b65bcbd38efb0fd35854 [file] [log] [blame]
Andy Yanb21f4b62014-12-05 14:26:31 +08001/*
2 * Copyright (C) 2011 Freescale Semiconductor, Inc.
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
8 */
9
10#ifndef __DW_HDMI__
11#define __DW_HDMI__
12
13#include <drm/drmP.h>
14
Russell Kingb5814ff2015-03-27 12:50:58 +000015struct dw_hdmi;
16
Neil Armstrongdef23aa2017-04-04 14:31:57 +020017/**
18 * DOC: Supported input formats and encodings
19 *
20 * Depending on the Hardware configuration of the Controller IP, it supports
21 * a subset of the following input formats and encodings on its internal
22 * 48bit bus.
23 *
24 * +----------------------+----------------------------------+------------------------------+
Jonathan Corbet38cb2662017-06-23 14:00:13 -060025 * | Format Name | Format Code | Encodings |
Neil Armstrongdef23aa2017-04-04 14:31:57 +020026 * +----------------------+----------------------------------+------------------------------+
Jonathan Corbet38cb2662017-06-23 14:00:13 -060027 * | RGB 4:4:4 8bit | ``MEDIA_BUS_FMT_RGB888_1X24`` | ``V4L2_YCBCR_ENC_DEFAULT`` |
Neil Armstrongdef23aa2017-04-04 14:31:57 +020028 * +----------------------+----------------------------------+------------------------------+
Jonathan Corbet38cb2662017-06-23 14:00:13 -060029 * | RGB 4:4:4 10bits | ``MEDIA_BUS_FMT_RGB101010_1X30`` | ``V4L2_YCBCR_ENC_DEFAULT`` |
Neil Armstrongdef23aa2017-04-04 14:31:57 +020030 * +----------------------+----------------------------------+------------------------------+
Jonathan Corbet38cb2662017-06-23 14:00:13 -060031 * | RGB 4:4:4 12bits | ``MEDIA_BUS_FMT_RGB121212_1X36`` | ``V4L2_YCBCR_ENC_DEFAULT`` |
Neil Armstrongdef23aa2017-04-04 14:31:57 +020032 * +----------------------+----------------------------------+------------------------------+
Jonathan Corbet38cb2662017-06-23 14:00:13 -060033 * | RGB 4:4:4 16bits | ``MEDIA_BUS_FMT_RGB161616_1X48`` | ``V4L2_YCBCR_ENC_DEFAULT`` |
Neil Armstrongdef23aa2017-04-04 14:31:57 +020034 * +----------------------+----------------------------------+------------------------------+
Jonathan Corbet38cb2662017-06-23 14:00:13 -060035 * | YCbCr 4:4:4 8bit | ``MEDIA_BUS_FMT_YUV8_1X24`` | ``V4L2_YCBCR_ENC_601`` |
36 * | | | or ``V4L2_YCBCR_ENC_709`` |
37 * | | | or ``V4L2_YCBCR_ENC_XV601`` |
38 * | | | or ``V4L2_YCBCR_ENC_XV709`` |
Neil Armstrongdef23aa2017-04-04 14:31:57 +020039 * +----------------------+----------------------------------+------------------------------+
Jonathan Corbet38cb2662017-06-23 14:00:13 -060040 * | YCbCr 4:4:4 10bits | ``MEDIA_BUS_FMT_YUV10_1X30`` | ``V4L2_YCBCR_ENC_601`` |
41 * | | | or ``V4L2_YCBCR_ENC_709`` |
42 * | | | or ``V4L2_YCBCR_ENC_XV601`` |
43 * | | | or ``V4L2_YCBCR_ENC_XV709`` |
Neil Armstrongdef23aa2017-04-04 14:31:57 +020044 * +----------------------+----------------------------------+------------------------------+
Jonathan Corbet38cb2662017-06-23 14:00:13 -060045 * | YCbCr 4:4:4 12bits | ``MEDIA_BUS_FMT_YUV12_1X36`` | ``V4L2_YCBCR_ENC_601`` |
46 * | | | or ``V4L2_YCBCR_ENC_709`` |
47 * | | | or ``V4L2_YCBCR_ENC_XV601`` |
48 * | | | or ``V4L2_YCBCR_ENC_XV709`` |
Neil Armstrongdef23aa2017-04-04 14:31:57 +020049 * +----------------------+----------------------------------+------------------------------+
Jonathan Corbet38cb2662017-06-23 14:00:13 -060050 * | YCbCr 4:4:4 16bits | ``MEDIA_BUS_FMT_YUV16_1X48`` | ``V4L2_YCBCR_ENC_601`` |
51 * | | | or ``V4L2_YCBCR_ENC_709`` |
52 * | | | or ``V4L2_YCBCR_ENC_XV601`` |
53 * | | | or ``V4L2_YCBCR_ENC_XV709`` |
Neil Armstrongdef23aa2017-04-04 14:31:57 +020054 * +----------------------+----------------------------------+------------------------------+
Jonathan Corbet38cb2662017-06-23 14:00:13 -060055 * | YCbCr 4:2:2 8bit | ``MEDIA_BUS_FMT_UYVY8_1X16`` | ``V4L2_YCBCR_ENC_601`` |
56 * | | | or ``V4L2_YCBCR_ENC_709`` |
Neil Armstrongdef23aa2017-04-04 14:31:57 +020057 * +----------------------+----------------------------------+------------------------------+
Jonathan Corbet38cb2662017-06-23 14:00:13 -060058 * | YCbCr 4:2:2 10bits | ``MEDIA_BUS_FMT_UYVY10_1X20`` | ``V4L2_YCBCR_ENC_601`` |
59 * | | | or ``V4L2_YCBCR_ENC_709`` |
Neil Armstrongdef23aa2017-04-04 14:31:57 +020060 * +----------------------+----------------------------------+------------------------------+
Jonathan Corbet38cb2662017-06-23 14:00:13 -060061 * | YCbCr 4:2:2 12bits | ``MEDIA_BUS_FMT_UYVY12_1X24`` | ``V4L2_YCBCR_ENC_601`` |
62 * | | | or ``V4L2_YCBCR_ENC_709`` |
Neil Armstrongdef23aa2017-04-04 14:31:57 +020063 * +----------------------+----------------------------------+------------------------------+
Jonathan Corbet38cb2662017-06-23 14:00:13 -060064 * | YCbCr 4:2:0 8bit | ``MEDIA_BUS_FMT_UYYVYY8_0_5X24`` | ``V4L2_YCBCR_ENC_601`` |
65 * | | | or ``V4L2_YCBCR_ENC_709`` |
Neil Armstrongdef23aa2017-04-04 14:31:57 +020066 * +----------------------+----------------------------------+------------------------------+
Jonathan Corbet38cb2662017-06-23 14:00:13 -060067 * | YCbCr 4:2:0 10bits | ``MEDIA_BUS_FMT_UYYVYY10_0_5X30``| ``V4L2_YCBCR_ENC_601`` |
68 * | | | or ``V4L2_YCBCR_ENC_709`` |
Neil Armstrongdef23aa2017-04-04 14:31:57 +020069 * +----------------------+----------------------------------+------------------------------+
Jonathan Corbet38cb2662017-06-23 14:00:13 -060070 * | YCbCr 4:2:0 12bits | ``MEDIA_BUS_FMT_UYYVYY12_0_5X36``| ``V4L2_YCBCR_ENC_601`` |
71 * | | | or ``V4L2_YCBCR_ENC_709`` |
Neil Armstrongdef23aa2017-04-04 14:31:57 +020072 * +----------------------+----------------------------------+------------------------------+
Jonathan Corbet38cb2662017-06-23 14:00:13 -060073 * | YCbCr 4:2:0 16bits | ``MEDIA_BUS_FMT_UYYVYY16_0_5X48``| ``V4L2_YCBCR_ENC_601`` |
74 * | | | or ``V4L2_YCBCR_ENC_709`` |
Neil Armstrongdef23aa2017-04-04 14:31:57 +020075 * +----------------------+----------------------------------+------------------------------+
76 */
77
Andy Yanb21f4b62014-12-05 14:26:31 +080078enum {
79 DW_HDMI_RES_8,
80 DW_HDMI_RES_10,
81 DW_HDMI_RES_12,
82 DW_HDMI_RES_MAX,
83};
84
Laurent Pinchartfaba6c32017-01-17 10:29:06 +020085enum dw_hdmi_phy_type {
86 DW_HDMI_PHY_DWC_HDMI_TX_PHY = 0x00,
87 DW_HDMI_PHY_DWC_MHL_PHY_HEAC = 0xb2,
88 DW_HDMI_PHY_DWC_MHL_PHY = 0xc2,
89 DW_HDMI_PHY_DWC_HDMI_3D_TX_PHY_HEAC = 0xe2,
90 DW_HDMI_PHY_DWC_HDMI_3D_TX_PHY = 0xf2,
91 DW_HDMI_PHY_DWC_HDMI20_TX_PHY = 0xf3,
92 DW_HDMI_PHY_VENDOR_PHY = 0xfe,
93};
94
Andy Yanb21f4b62014-12-05 14:26:31 +080095struct dw_hdmi_mpll_config {
96 unsigned long mpixelclock;
97 struct {
98 u16 cpce;
99 u16 gmp;
100 } res[DW_HDMI_RES_MAX];
101};
102
103struct dw_hdmi_curr_ctrl {
104 unsigned long mpixelclock;
105 u16 curr[DW_HDMI_RES_MAX];
106};
107
Yakir Yang034705a2015-03-31 23:56:10 -0400108struct dw_hdmi_phy_config {
Andy Yanb21f4b62014-12-05 14:26:31 +0800109 unsigned long mpixelclock;
110 u16 sym_ctr; /*clock symbol and transmitter control*/
111 u16 term; /*transmission termination value*/
Yakir Yang034705a2015-03-31 23:56:10 -0400112 u16 vlev_ctr; /* voltage level control */
Andy Yanb21f4b62014-12-05 14:26:31 +0800113};
114
Laurent Pinchartf1585f62017-03-06 01:36:15 +0200115struct dw_hdmi_phy_ops {
116 int (*init)(struct dw_hdmi *hdmi, void *data,
117 struct drm_display_mode *mode);
118 void (*disable)(struct dw_hdmi *hdmi, void *data);
119 enum drm_connector_status (*read_hpd)(struct dw_hdmi *hdmi, void *data);
Neil Armstrong386d3292017-04-04 14:31:59 +0200120 void (*update_hpd)(struct dw_hdmi *hdmi, void *data,
121 bool force, bool disabled, bool rxsense);
122 void (*setup_hpd)(struct dw_hdmi *hdmi, void *data);
Laurent Pinchartf1585f62017-03-06 01:36:15 +0200123};
124
Andy Yanb21f4b62014-12-05 14:26:31 +0800125struct dw_hdmi_plat_data {
Neil Armstrong80e2f972017-03-03 19:20:06 +0200126 struct regmap *regm;
Laurent Pinchartf1585f62017-03-06 01:36:15 +0200127 enum drm_mode_status (*mode_valid)(struct drm_connector *connector,
Jose Abreub0febde2017-05-25 15:19:19 +0100128 const struct drm_display_mode *mode);
Neil Armstrongdef23aa2017-04-04 14:31:57 +0200129 unsigned long input_bus_format;
130 unsigned long input_bus_encoding;
Laurent Pinchartf1585f62017-03-06 01:36:15 +0200131
132 /* Vendor PHY support */
133 const struct dw_hdmi_phy_ops *phy_ops;
134 const char *phy_name;
135 void *phy_data;
136
137 /* Synopsys PHY support */
Andy Yanb21f4b62014-12-05 14:26:31 +0800138 const struct dw_hdmi_mpll_config *mpll_cfg;
139 const struct dw_hdmi_curr_ctrl *cur_ctr;
Yakir Yang034705a2015-03-31 23:56:10 -0400140 const struct dw_hdmi_phy_config *phy_config;
Kieran Bingham2ef9dfe2017-03-03 19:20:04 +0200141 int (*configure_phy)(struct dw_hdmi *hdmi,
142 const struct dw_hdmi_plat_data *pdata,
143 unsigned long mpixelclock);
Andy Yanb21f4b62014-12-05 14:26:31 +0800144};
145
Jernej Skrabeceea034a2018-02-14 21:08:59 +0100146struct dw_hdmi *dw_hdmi_probe(struct platform_device *pdev,
147 const struct dw_hdmi_plat_data *plat_data);
148void dw_hdmi_remove(struct dw_hdmi *hdmi);
149void dw_hdmi_unbind(struct dw_hdmi *hdmi);
150struct dw_hdmi *dw_hdmi_bind(struct platform_device *pdev,
151 struct drm_encoder *encoder,
152 const struct dw_hdmi_plat_data *plat_data);
Russell Kingb5814ff2015-03-27 12:50:58 +0000153
Neil Armstrong386d3292017-04-04 14:31:59 +0200154void dw_hdmi_setup_rx_sense(struct device *dev, bool hpd, bool rx_sense);
155
Russell Kingb5814ff2015-03-27 12:50:58 +0000156void dw_hdmi_set_sample_rate(struct dw_hdmi *hdmi, unsigned int rate);
Russell Kingb90120a2015-03-27 12:59:58 +0000157void dw_hdmi_audio_enable(struct dw_hdmi *hdmi);
158void dw_hdmi_audio_disable(struct dw_hdmi *hdmi);
Russell Kingb5814ff2015-03-27 12:50:58 +0000159
Kieran Bingham2ef9dfe2017-03-03 19:20:04 +0200160/* PHY configuration */
Jernej Skrabec57659162018-02-14 21:08:58 +0100161void dw_hdmi_phy_i2c_set_addr(struct dw_hdmi *hdmi, u8 address);
Kieran Bingham2ef9dfe2017-03-03 19:20:04 +0200162void dw_hdmi_phy_i2c_write(struct dw_hdmi *hdmi, unsigned short data,
163 unsigned char addr);
164
Jernej Skrabec57659162018-02-14 21:08:58 +0100165void dw_hdmi_phy_gen2_pddq(struct dw_hdmi *hdmi, u8 enable);
166void dw_hdmi_phy_gen2_txpwron(struct dw_hdmi *hdmi, u8 enable);
167void dw_hdmi_phy_reset(struct dw_hdmi *hdmi);
168
169enum drm_connector_status dw_hdmi_phy_read_hpd(struct dw_hdmi *hdmi,
170 void *data);
171void dw_hdmi_phy_update_hpd(struct dw_hdmi *hdmi, void *data,
172 bool force, bool disabled, bool rxsense);
173void dw_hdmi_phy_setup_hpd(struct dw_hdmi *hdmi, void *data);
174
Andy Yanb21f4b62014-12-05 14:26:31 +0800175#endif /* __IMX_HDMI_H__ */