drm/msm: basic KMS driver for snapdragon
The snapdragon chips have multiple different display controllers,
depending on which chip variant/version. (As far as I can tell, current
devices have either MDP3 or MDP4, and upcoming devices have MDSS.) And
then external to the display controller are HDMI, DSI, etc. blocks which
may be shared across devices which have different display controller
blocks.
To more easily add support for different display controller blocks, the
display controller specific bits are split out into a "kms" module,
which provides the kms plane/crtc/encoder objects.
The external HDMI, DSI, etc. blocks are part encoder, and part connector
currently. But I think I will pull in the drm_bridge patches from
chromeos tree, and split them into a bridge+connector, with the
registers that need to be set in modeset handled by the bridge. This
would remove the 'msm_connector' base class. But some things need to be
double checked to make sure I could get the correct ON/OFF sequencing..
This patch adds support for mdp4 crtc (including hw cursor), dtv encoder
(part of MDP4 block), and hdmi.
Signed-off-by: Rob Clark <robdclark@gmail.com>
2013-06-26 16:44:06 +00:00
|
|
|
/*
|
|
|
|
* Copyright (C) 2013 Red Hat
|
|
|
|
* Author: Rob Clark <robdclark@gmail.com>
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify it
|
|
|
|
* under the terms of the GNU General Public License version 2 as published by
|
|
|
|
* the Free Software Foundation.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful, but WITHOUT
|
|
|
|
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
|
|
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
|
|
|
* more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License along with
|
|
|
|
* this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <linux/gpio.h>
|
|
|
|
|
|
|
|
#include "hdmi.h"
|
|
|
|
|
|
|
|
struct hdmi_connector {
|
2013-08-30 17:02:15 +00:00
|
|
|
struct drm_connector base;
|
|
|
|
struct hdmi *hdmi;
|
drm/msm: basic KMS driver for snapdragon
The snapdragon chips have multiple different display controllers,
depending on which chip variant/version. (As far as I can tell, current
devices have either MDP3 or MDP4, and upcoming devices have MDSS.) And
then external to the display controller are HDMI, DSI, etc. blocks which
may be shared across devices which have different display controller
blocks.
To more easily add support for different display controller blocks, the
display controller specific bits are split out into a "kms" module,
which provides the kms plane/crtc/encoder objects.
The external HDMI, DSI, etc. blocks are part encoder, and part connector
currently. But I think I will pull in the drm_bridge patches from
chromeos tree, and split them into a bridge+connector, with the
registers that need to be set in modeset handled by the bridge. This
would remove the 'msm_connector' base class. But some things need to be
double checked to make sure I could get the correct ON/OFF sequencing..
This patch adds support for mdp4 crtc (including hw cursor), dtv encoder
(part of MDP4 block), and hdmi.
Signed-off-by: Rob Clark <robdclark@gmail.com>
2013-06-26 16:44:06 +00:00
|
|
|
};
|
|
|
|
#define to_hdmi_connector(x) container_of(x, struct hdmi_connector, base)
|
|
|
|
|
|
|
|
static int gpio_config(struct hdmi *hdmi, bool on)
|
|
|
|
{
|
|
|
|
struct drm_device *dev = hdmi->dev;
|
|
|
|
struct hdmi_platform_config *config =
|
|
|
|
hdmi->pdev->dev.platform_data;
|
|
|
|
int ret;
|
|
|
|
|
|
|
|
if (on) {
|
|
|
|
ret = gpio_request(config->ddc_clk_gpio, "HDMI_DDC_CLK");
|
|
|
|
if (ret) {
|
|
|
|
dev_err(dev->dev, "'%s'(%d) gpio_request failed: %d\n",
|
|
|
|
"HDMI_DDC_CLK", config->ddc_clk_gpio, ret);
|
|
|
|
goto error1;
|
|
|
|
}
|
|
|
|
ret = gpio_request(config->ddc_data_gpio, "HDMI_DDC_DATA");
|
|
|
|
if (ret) {
|
|
|
|
dev_err(dev->dev, "'%s'(%d) gpio_request failed: %d\n",
|
|
|
|
"HDMI_DDC_DATA", config->ddc_data_gpio, ret);
|
|
|
|
goto error2;
|
|
|
|
}
|
|
|
|
ret = gpio_request(config->hpd_gpio, "HDMI_HPD");
|
|
|
|
if (ret) {
|
|
|
|
dev_err(dev->dev, "'%s'(%d) gpio_request failed: %d\n",
|
|
|
|
"HDMI_HPD", config->hpd_gpio, ret);
|
|
|
|
goto error3;
|
|
|
|
}
|
|
|
|
if (config->pmic_gpio != -1) {
|
|
|
|
ret = gpio_request(config->pmic_gpio, "PMIC_HDMI_MUX_SEL");
|
|
|
|
if (ret) {
|
|
|
|
dev_err(dev->dev, "'%s'(%d) gpio_request failed: %d\n",
|
|
|
|
"PMIC_HDMI_MUX_SEL", config->pmic_gpio, ret);
|
|
|
|
goto error4;
|
|
|
|
}
|
|
|
|
gpio_set_value_cansleep(config->pmic_gpio, 0);
|
|
|
|
}
|
|
|
|
DBG("gpio on");
|
|
|
|
} else {
|
|
|
|
gpio_free(config->ddc_clk_gpio);
|
|
|
|
gpio_free(config->ddc_data_gpio);
|
|
|
|
gpio_free(config->hpd_gpio);
|
|
|
|
|
|
|
|
if (config->pmic_gpio != -1) {
|
|
|
|
gpio_set_value_cansleep(config->pmic_gpio, 1);
|
|
|
|
gpio_free(config->pmic_gpio);
|
|
|
|
}
|
|
|
|
DBG("gpio off");
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
error4:
|
|
|
|
gpio_free(config->hpd_gpio);
|
|
|
|
error3:
|
|
|
|
gpio_free(config->ddc_data_gpio);
|
|
|
|
error2:
|
|
|
|
gpio_free(config->ddc_clk_gpio);
|
|
|
|
error1:
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int hpd_enable(struct hdmi_connector *hdmi_connector)
|
|
|
|
{
|
2013-08-30 17:02:15 +00:00
|
|
|
struct hdmi *hdmi = hdmi_connector->hdmi;
|
|
|
|
struct drm_device *dev = hdmi_connector->base.dev;
|
drm/msm: basic KMS driver for snapdragon
The snapdragon chips have multiple different display controllers,
depending on which chip variant/version. (As far as I can tell, current
devices have either MDP3 or MDP4, and upcoming devices have MDSS.) And
then external to the display controller are HDMI, DSI, etc. blocks which
may be shared across devices which have different display controller
blocks.
To more easily add support for different display controller blocks, the
display controller specific bits are split out into a "kms" module,
which provides the kms plane/crtc/encoder objects.
The external HDMI, DSI, etc. blocks are part encoder, and part connector
currently. But I think I will pull in the drm_bridge patches from
chromeos tree, and split them into a bridge+connector, with the
registers that need to be set in modeset handled by the bridge. This
would remove the 'msm_connector' base class. But some things need to be
double checked to make sure I could get the correct ON/OFF sequencing..
This patch adds support for mdp4 crtc (including hw cursor), dtv encoder
(part of MDP4 block), and hdmi.
Signed-off-by: Rob Clark <robdclark@gmail.com>
2013-06-26 16:44:06 +00:00
|
|
|
struct hdmi_phy *phy = hdmi->phy;
|
|
|
|
uint32_t hpd_ctrl;
|
|
|
|
int ret;
|
|
|
|
|
|
|
|
ret = gpio_config(hdmi, true);
|
|
|
|
if (ret) {
|
|
|
|
dev_err(dev->dev, "failed to configure GPIOs: %d\n", ret);
|
|
|
|
goto fail;
|
|
|
|
}
|
|
|
|
|
|
|
|
ret = clk_prepare_enable(hdmi->clk);
|
|
|
|
if (ret) {
|
|
|
|
dev_err(dev->dev, "failed to enable 'clk': %d\n", ret);
|
|
|
|
goto fail;
|
|
|
|
}
|
|
|
|
|
|
|
|
ret = clk_prepare_enable(hdmi->m_pclk);
|
|
|
|
if (ret) {
|
|
|
|
dev_err(dev->dev, "failed to enable 'm_pclk': %d\n", ret);
|
|
|
|
goto fail;
|
|
|
|
}
|
|
|
|
|
|
|
|
ret = clk_prepare_enable(hdmi->s_pclk);
|
|
|
|
if (ret) {
|
|
|
|
dev_err(dev->dev, "failed to enable 's_pclk': %d\n", ret);
|
|
|
|
goto fail;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (hdmi->mpp0)
|
|
|
|
ret = regulator_enable(hdmi->mpp0);
|
|
|
|
if (!ret)
|
|
|
|
ret = regulator_enable(hdmi->mvs);
|
|
|
|
if (ret) {
|
|
|
|
dev_err(dev->dev, "failed to enable regulators: %d\n", ret);
|
|
|
|
goto fail;
|
|
|
|
}
|
|
|
|
|
|
|
|
hdmi_set_mode(hdmi, false);
|
|
|
|
phy->funcs->reset(phy);
|
|
|
|
hdmi_set_mode(hdmi, true);
|
|
|
|
|
|
|
|
hdmi_write(hdmi, REG_HDMI_USEC_REFTIMER, 0x0001001b);
|
|
|
|
|
|
|
|
/* enable HPD events: */
|
|
|
|
hdmi_write(hdmi, REG_HDMI_HPD_INT_CTRL,
|
|
|
|
HDMI_HPD_INT_CTRL_INT_CONNECT |
|
|
|
|
HDMI_HPD_INT_CTRL_INT_EN);
|
|
|
|
|
|
|
|
/* set timeout to 4.1ms (max) for hardware debounce */
|
|
|
|
hpd_ctrl = hdmi_read(hdmi, REG_HDMI_HPD_CTRL);
|
|
|
|
hpd_ctrl |= HDMI_HPD_CTRL_TIMEOUT(0x1fff);
|
|
|
|
|
|
|
|
/* Toggle HPD circuit to trigger HPD sense */
|
|
|
|
hdmi_write(hdmi, REG_HDMI_HPD_CTRL,
|
|
|
|
~HDMI_HPD_CTRL_ENABLE & hpd_ctrl);
|
|
|
|
hdmi_write(hdmi, REG_HDMI_HPD_CTRL,
|
|
|
|
HDMI_HPD_CTRL_ENABLE | hpd_ctrl);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
fail:
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int hdp_disable(struct hdmi_connector *hdmi_connector)
|
|
|
|
{
|
2013-08-30 17:02:15 +00:00
|
|
|
struct hdmi *hdmi = hdmi_connector->hdmi;
|
|
|
|
struct drm_device *dev = hdmi_connector->base.dev;
|
drm/msm: basic KMS driver for snapdragon
The snapdragon chips have multiple different display controllers,
depending on which chip variant/version. (As far as I can tell, current
devices have either MDP3 or MDP4, and upcoming devices have MDSS.) And
then external to the display controller are HDMI, DSI, etc. blocks which
may be shared across devices which have different display controller
blocks.
To more easily add support for different display controller blocks, the
display controller specific bits are split out into a "kms" module,
which provides the kms plane/crtc/encoder objects.
The external HDMI, DSI, etc. blocks are part encoder, and part connector
currently. But I think I will pull in the drm_bridge patches from
chromeos tree, and split them into a bridge+connector, with the
registers that need to be set in modeset handled by the bridge. This
would remove the 'msm_connector' base class. But some things need to be
double checked to make sure I could get the correct ON/OFF sequencing..
This patch adds support for mdp4 crtc (including hw cursor), dtv encoder
(part of MDP4 block), and hdmi.
Signed-off-by: Rob Clark <robdclark@gmail.com>
2013-06-26 16:44:06 +00:00
|
|
|
int ret = 0;
|
|
|
|
|
|
|
|
/* Disable HPD interrupt */
|
|
|
|
hdmi_write(hdmi, REG_HDMI_HPD_INT_CTRL, 0);
|
|
|
|
|
|
|
|
hdmi_set_mode(hdmi, false);
|
|
|
|
|
|
|
|
if (hdmi->mpp0)
|
|
|
|
ret = regulator_disable(hdmi->mpp0);
|
|
|
|
if (!ret)
|
|
|
|
ret = regulator_disable(hdmi->mvs);
|
|
|
|
if (ret) {
|
|
|
|
dev_err(dev->dev, "failed to enable regulators: %d\n", ret);
|
|
|
|
goto fail;
|
|
|
|
}
|
|
|
|
|
|
|
|
clk_disable_unprepare(hdmi->clk);
|
|
|
|
clk_disable_unprepare(hdmi->m_pclk);
|
|
|
|
clk_disable_unprepare(hdmi->s_pclk);
|
|
|
|
|
|
|
|
ret = gpio_config(hdmi, false);
|
|
|
|
if (ret) {
|
|
|
|
dev_err(dev->dev, "failed to unconfigure GPIOs: %d\n", ret);
|
|
|
|
goto fail;
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
fail:
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
void hdmi_connector_irq(struct drm_connector *connector)
|
|
|
|
{
|
2013-08-30 17:02:15 +00:00
|
|
|
struct hdmi_connector *hdmi_connector = to_hdmi_connector(connector);
|
|
|
|
struct hdmi *hdmi = hdmi_connector->hdmi;
|
drm/msm: basic KMS driver for snapdragon
The snapdragon chips have multiple different display controllers,
depending on which chip variant/version. (As far as I can tell, current
devices have either MDP3 or MDP4, and upcoming devices have MDSS.) And
then external to the display controller are HDMI, DSI, etc. blocks which
may be shared across devices which have different display controller
blocks.
To more easily add support for different display controller blocks, the
display controller specific bits are split out into a "kms" module,
which provides the kms plane/crtc/encoder objects.
The external HDMI, DSI, etc. blocks are part encoder, and part connector
currently. But I think I will pull in the drm_bridge patches from
chromeos tree, and split them into a bridge+connector, with the
registers that need to be set in modeset handled by the bridge. This
would remove the 'msm_connector' base class. But some things need to be
double checked to make sure I could get the correct ON/OFF sequencing..
This patch adds support for mdp4 crtc (including hw cursor), dtv encoder
(part of MDP4 block), and hdmi.
Signed-off-by: Rob Clark <robdclark@gmail.com>
2013-06-26 16:44:06 +00:00
|
|
|
uint32_t hpd_int_status, hpd_int_ctrl;
|
|
|
|
|
|
|
|
/* Process HPD: */
|
|
|
|
hpd_int_status = hdmi_read(hdmi, REG_HDMI_HPD_INT_STATUS);
|
|
|
|
hpd_int_ctrl = hdmi_read(hdmi, REG_HDMI_HPD_INT_CTRL);
|
|
|
|
|
|
|
|
if ((hpd_int_ctrl & HDMI_HPD_INT_CTRL_INT_EN) &&
|
|
|
|
(hpd_int_status & HDMI_HPD_INT_STATUS_INT)) {
|
|
|
|
bool detected = !!(hpd_int_status & HDMI_HPD_INT_STATUS_CABLE_DETECTED);
|
|
|
|
|
|
|
|
DBG("status=%04x, ctrl=%04x", hpd_int_status, hpd_int_ctrl);
|
|
|
|
|
|
|
|
/* ack the irq: */
|
|
|
|
hdmi_write(hdmi, REG_HDMI_HPD_INT_CTRL,
|
|
|
|
hpd_int_ctrl | HDMI_HPD_INT_CTRL_INT_ACK);
|
|
|
|
|
|
|
|
drm_helper_hpd_irq_event(connector->dev);
|
|
|
|
|
|
|
|
/* detect disconnect if we are connected or visa versa: */
|
|
|
|
hpd_int_ctrl = HDMI_HPD_INT_CTRL_INT_EN;
|
|
|
|
if (!detected)
|
|
|
|
hpd_int_ctrl |= HDMI_HPD_INT_CTRL_INT_CONNECT;
|
|
|
|
hdmi_write(hdmi, REG_HDMI_HPD_INT_CTRL, hpd_int_ctrl);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static enum drm_connector_status hdmi_connector_detect(
|
|
|
|
struct drm_connector *connector, bool force)
|
|
|
|
{
|
2013-08-30 17:02:15 +00:00
|
|
|
struct hdmi_connector *hdmi_connector = to_hdmi_connector(connector);
|
|
|
|
struct hdmi *hdmi = hdmi_connector->hdmi;
|
drm/msm: basic KMS driver for snapdragon
The snapdragon chips have multiple different display controllers,
depending on which chip variant/version. (As far as I can tell, current
devices have either MDP3 or MDP4, and upcoming devices have MDSS.) And
then external to the display controller are HDMI, DSI, etc. blocks which
may be shared across devices which have different display controller
blocks.
To more easily add support for different display controller blocks, the
display controller specific bits are split out into a "kms" module,
which provides the kms plane/crtc/encoder objects.
The external HDMI, DSI, etc. blocks are part encoder, and part connector
currently. But I think I will pull in the drm_bridge patches from
chromeos tree, and split them into a bridge+connector, with the
registers that need to be set in modeset handled by the bridge. This
would remove the 'msm_connector' base class. But some things need to be
double checked to make sure I could get the correct ON/OFF sequencing..
This patch adds support for mdp4 crtc (including hw cursor), dtv encoder
(part of MDP4 block), and hdmi.
Signed-off-by: Rob Clark <robdclark@gmail.com>
2013-06-26 16:44:06 +00:00
|
|
|
uint32_t hpd_int_status;
|
|
|
|
int retry = 20;
|
|
|
|
|
|
|
|
hpd_int_status = hdmi_read(hdmi, REG_HDMI_HPD_INT_STATUS);
|
|
|
|
|
|
|
|
/* sense seems to in some cases be momentarily de-asserted, don't
|
|
|
|
* let that trick us into thinking the monitor is gone:
|
|
|
|
*/
|
|
|
|
while (retry-- && !(hpd_int_status & HDMI_HPD_INT_STATUS_CABLE_DETECTED)) {
|
|
|
|
mdelay(10);
|
|
|
|
hpd_int_status = hdmi_read(hdmi, REG_HDMI_HPD_INT_STATUS);
|
|
|
|
DBG("status=%08x", hpd_int_status);
|
|
|
|
}
|
|
|
|
|
|
|
|
return (hpd_int_status & HDMI_HPD_INT_STATUS_CABLE_DETECTED) ?
|
|
|
|
connector_status_connected : connector_status_disconnected;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void hdmi_connector_destroy(struct drm_connector *connector)
|
|
|
|
{
|
2013-08-30 17:02:15 +00:00
|
|
|
struct hdmi_connector *hdmi_connector = to_hdmi_connector(connector);
|
drm/msm: basic KMS driver for snapdragon
The snapdragon chips have multiple different display controllers,
depending on which chip variant/version. (As far as I can tell, current
devices have either MDP3 or MDP4, and upcoming devices have MDSS.) And
then external to the display controller are HDMI, DSI, etc. blocks which
may be shared across devices which have different display controller
blocks.
To more easily add support for different display controller blocks, the
display controller specific bits are split out into a "kms" module,
which provides the kms plane/crtc/encoder objects.
The external HDMI, DSI, etc. blocks are part encoder, and part connector
currently. But I think I will pull in the drm_bridge patches from
chromeos tree, and split them into a bridge+connector, with the
registers that need to be set in modeset handled by the bridge. This
would remove the 'msm_connector' base class. But some things need to be
double checked to make sure I could get the correct ON/OFF sequencing..
This patch adds support for mdp4 crtc (including hw cursor), dtv encoder
(part of MDP4 block), and hdmi.
Signed-off-by: Rob Clark <robdclark@gmail.com>
2013-06-26 16:44:06 +00:00
|
|
|
|
|
|
|
hdp_disable(hdmi_connector);
|
|
|
|
|
|
|
|
drm_sysfs_connector_remove(connector);
|
|
|
|
drm_connector_cleanup(connector);
|
|
|
|
|
2013-08-30 17:02:15 +00:00
|
|
|
hdmi_unreference(hdmi_connector->hdmi);
|
drm/msm: basic KMS driver for snapdragon
The snapdragon chips have multiple different display controllers,
depending on which chip variant/version. (As far as I can tell, current
devices have either MDP3 or MDP4, and upcoming devices have MDSS.) And
then external to the display controller are HDMI, DSI, etc. blocks which
may be shared across devices which have different display controller
blocks.
To more easily add support for different display controller blocks, the
display controller specific bits are split out into a "kms" module,
which provides the kms plane/crtc/encoder objects.
The external HDMI, DSI, etc. blocks are part encoder, and part connector
currently. But I think I will pull in the drm_bridge patches from
chromeos tree, and split them into a bridge+connector, with the
registers that need to be set in modeset handled by the bridge. This
would remove the 'msm_connector' base class. But some things need to be
double checked to make sure I could get the correct ON/OFF sequencing..
This patch adds support for mdp4 crtc (including hw cursor), dtv encoder
(part of MDP4 block), and hdmi.
Signed-off-by: Rob Clark <robdclark@gmail.com>
2013-06-26 16:44:06 +00:00
|
|
|
|
|
|
|
kfree(hdmi_connector);
|
|
|
|
}
|
|
|
|
|
|
|
|
static int hdmi_connector_get_modes(struct drm_connector *connector)
|
|
|
|
{
|
2013-08-30 17:02:15 +00:00
|
|
|
struct hdmi_connector *hdmi_connector = to_hdmi_connector(connector);
|
|
|
|
struct hdmi *hdmi = hdmi_connector->hdmi;
|
drm/msm: basic KMS driver for snapdragon
The snapdragon chips have multiple different display controllers,
depending on which chip variant/version. (As far as I can tell, current
devices have either MDP3 or MDP4, and upcoming devices have MDSS.) And
then external to the display controller are HDMI, DSI, etc. blocks which
may be shared across devices which have different display controller
blocks.
To more easily add support for different display controller blocks, the
display controller specific bits are split out into a "kms" module,
which provides the kms plane/crtc/encoder objects.
The external HDMI, DSI, etc. blocks are part encoder, and part connector
currently. But I think I will pull in the drm_bridge patches from
chromeos tree, and split them into a bridge+connector, with the
registers that need to be set in modeset handled by the bridge. This
would remove the 'msm_connector' base class. But some things need to be
double checked to make sure I could get the correct ON/OFF sequencing..
This patch adds support for mdp4 crtc (including hw cursor), dtv encoder
(part of MDP4 block), and hdmi.
Signed-off-by: Rob Clark <robdclark@gmail.com>
2013-06-26 16:44:06 +00:00
|
|
|
struct edid *edid;
|
|
|
|
uint32_t hdmi_ctrl;
|
|
|
|
int ret = 0;
|
|
|
|
|
|
|
|
hdmi_ctrl = hdmi_read(hdmi, REG_HDMI_CTRL);
|
|
|
|
hdmi_write(hdmi, REG_HDMI_CTRL, hdmi_ctrl | HDMI_CTRL_ENABLE);
|
|
|
|
|
|
|
|
edid = drm_get_edid(connector, hdmi->i2c);
|
|
|
|
|
|
|
|
hdmi_write(hdmi, REG_HDMI_CTRL, hdmi_ctrl);
|
|
|
|
|
|
|
|
drm_mode_connector_update_edid_property(connector, edid);
|
|
|
|
|
|
|
|
if (edid) {
|
|
|
|
ret = drm_add_edid_modes(connector, edid);
|
|
|
|
kfree(edid);
|
|
|
|
}
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int hdmi_connector_mode_valid(struct drm_connector *connector,
|
|
|
|
struct drm_display_mode *mode)
|
|
|
|
{
|
2013-08-30 17:02:15 +00:00
|
|
|
struct hdmi_connector *hdmi_connector = to_hdmi_connector(connector);
|
drm/msm: basic KMS driver for snapdragon
The snapdragon chips have multiple different display controllers,
depending on which chip variant/version. (As far as I can tell, current
devices have either MDP3 or MDP4, and upcoming devices have MDSS.) And
then external to the display controller are HDMI, DSI, etc. blocks which
may be shared across devices which have different display controller
blocks.
To more easily add support for different display controller blocks, the
display controller specific bits are split out into a "kms" module,
which provides the kms plane/crtc/encoder objects.
The external HDMI, DSI, etc. blocks are part encoder, and part connector
currently. But I think I will pull in the drm_bridge patches from
chromeos tree, and split them into a bridge+connector, with the
registers that need to be set in modeset handled by the bridge. This
would remove the 'msm_connector' base class. But some things need to be
double checked to make sure I could get the correct ON/OFF sequencing..
This patch adds support for mdp4 crtc (including hw cursor), dtv encoder
(part of MDP4 block), and hdmi.
Signed-off-by: Rob Clark <robdclark@gmail.com>
2013-06-26 16:44:06 +00:00
|
|
|
struct msm_drm_private *priv = connector->dev->dev_private;
|
|
|
|
struct msm_kms *kms = priv->kms;
|
|
|
|
long actual, requested;
|
|
|
|
|
|
|
|
requested = 1000 * mode->clock;
|
|
|
|
actual = kms->funcs->round_pixclk(kms,
|
2013-08-30 17:02:15 +00:00
|
|
|
requested, hdmi_connector->hdmi->encoder);
|
drm/msm: basic KMS driver for snapdragon
The snapdragon chips have multiple different display controllers,
depending on which chip variant/version. (As far as I can tell, current
devices have either MDP3 or MDP4, and upcoming devices have MDSS.) And
then external to the display controller are HDMI, DSI, etc. blocks which
may be shared across devices which have different display controller
blocks.
To more easily add support for different display controller blocks, the
display controller specific bits are split out into a "kms" module,
which provides the kms plane/crtc/encoder objects.
The external HDMI, DSI, etc. blocks are part encoder, and part connector
currently. But I think I will pull in the drm_bridge patches from
chromeos tree, and split them into a bridge+connector, with the
registers that need to be set in modeset handled by the bridge. This
would remove the 'msm_connector' base class. But some things need to be
double checked to make sure I could get the correct ON/OFF sequencing..
This patch adds support for mdp4 crtc (including hw cursor), dtv encoder
(part of MDP4 block), and hdmi.
Signed-off-by: Rob Clark <robdclark@gmail.com>
2013-06-26 16:44:06 +00:00
|
|
|
|
|
|
|
DBG("requested=%ld, actual=%ld", requested, actual);
|
|
|
|
|
|
|
|
if (actual != requested)
|
|
|
|
return MODE_CLOCK_RANGE;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2013-08-30 17:02:15 +00:00
|
|
|
static struct drm_encoder *
|
|
|
|
hdmi_connector_best_encoder(struct drm_connector *connector)
|
|
|
|
{
|
|
|
|
struct hdmi_connector *hdmi_connector = to_hdmi_connector(connector);
|
|
|
|
return hdmi_connector->hdmi->encoder;
|
|
|
|
}
|
|
|
|
|
drm/msm: basic KMS driver for snapdragon
The snapdragon chips have multiple different display controllers,
depending on which chip variant/version. (As far as I can tell, current
devices have either MDP3 or MDP4, and upcoming devices have MDSS.) And
then external to the display controller are HDMI, DSI, etc. blocks which
may be shared across devices which have different display controller
blocks.
To more easily add support for different display controller blocks, the
display controller specific bits are split out into a "kms" module,
which provides the kms plane/crtc/encoder objects.
The external HDMI, DSI, etc. blocks are part encoder, and part connector
currently. But I think I will pull in the drm_bridge patches from
chromeos tree, and split them into a bridge+connector, with the
registers that need to be set in modeset handled by the bridge. This
would remove the 'msm_connector' base class. But some things need to be
double checked to make sure I could get the correct ON/OFF sequencing..
This patch adds support for mdp4 crtc (including hw cursor), dtv encoder
(part of MDP4 block), and hdmi.
Signed-off-by: Rob Clark <robdclark@gmail.com>
2013-06-26 16:44:06 +00:00
|
|
|
static const struct drm_connector_funcs hdmi_connector_funcs = {
|
|
|
|
.dpms = drm_helper_connector_dpms,
|
|
|
|
.detect = hdmi_connector_detect,
|
|
|
|
.fill_modes = drm_helper_probe_single_connector_modes,
|
|
|
|
.destroy = hdmi_connector_destroy,
|
|
|
|
};
|
|
|
|
|
|
|
|
static const struct drm_connector_helper_funcs hdmi_connector_helper_funcs = {
|
|
|
|
.get_modes = hdmi_connector_get_modes,
|
|
|
|
.mode_valid = hdmi_connector_mode_valid,
|
2013-08-30 17:02:15 +00:00
|
|
|
.best_encoder = hdmi_connector_best_encoder,
|
drm/msm: basic KMS driver for snapdragon
The snapdragon chips have multiple different display controllers,
depending on which chip variant/version. (As far as I can tell, current
devices have either MDP3 or MDP4, and upcoming devices have MDSS.) And
then external to the display controller are HDMI, DSI, etc. blocks which
may be shared across devices which have different display controller
blocks.
To more easily add support for different display controller blocks, the
display controller specific bits are split out into a "kms" module,
which provides the kms plane/crtc/encoder objects.
The external HDMI, DSI, etc. blocks are part encoder, and part connector
currently. But I think I will pull in the drm_bridge patches from
chromeos tree, and split them into a bridge+connector, with the
registers that need to be set in modeset handled by the bridge. This
would remove the 'msm_connector' base class. But some things need to be
double checked to make sure I could get the correct ON/OFF sequencing..
This patch adds support for mdp4 crtc (including hw cursor), dtv encoder
(part of MDP4 block), and hdmi.
Signed-off-by: Rob Clark <robdclark@gmail.com>
2013-06-26 16:44:06 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
/* initialize connector */
|
2013-08-30 17:02:15 +00:00
|
|
|
struct drm_connector *hdmi_connector_init(struct hdmi *hdmi)
|
drm/msm: basic KMS driver for snapdragon
The snapdragon chips have multiple different display controllers,
depending on which chip variant/version. (As far as I can tell, current
devices have either MDP3 or MDP4, and upcoming devices have MDSS.) And
then external to the display controller are HDMI, DSI, etc. blocks which
may be shared across devices which have different display controller
blocks.
To more easily add support for different display controller blocks, the
display controller specific bits are split out into a "kms" module,
which provides the kms plane/crtc/encoder objects.
The external HDMI, DSI, etc. blocks are part encoder, and part connector
currently. But I think I will pull in the drm_bridge patches from
chromeos tree, and split them into a bridge+connector, with the
registers that need to be set in modeset handled by the bridge. This
would remove the 'msm_connector' base class. But some things need to be
double checked to make sure I could get the correct ON/OFF sequencing..
This patch adds support for mdp4 crtc (including hw cursor), dtv encoder
(part of MDP4 block), and hdmi.
Signed-off-by: Rob Clark <robdclark@gmail.com>
2013-06-26 16:44:06 +00:00
|
|
|
{
|
|
|
|
struct drm_connector *connector = NULL;
|
|
|
|
struct hdmi_connector *hdmi_connector;
|
|
|
|
int ret;
|
|
|
|
|
|
|
|
hdmi_connector = kzalloc(sizeof(*hdmi_connector), GFP_KERNEL);
|
|
|
|
if (!hdmi_connector) {
|
|
|
|
ret = -ENOMEM;
|
|
|
|
goto fail;
|
|
|
|
}
|
|
|
|
|
2013-08-30 17:02:15 +00:00
|
|
|
hdmi_connector->hdmi = hdmi_reference(hdmi);
|
|
|
|
|
|
|
|
connector = &hdmi_connector->base;
|
drm/msm: basic KMS driver for snapdragon
The snapdragon chips have multiple different display controllers,
depending on which chip variant/version. (As far as I can tell, current
devices have either MDP3 or MDP4, and upcoming devices have MDSS.) And
then external to the display controller are HDMI, DSI, etc. blocks which
may be shared across devices which have different display controller
blocks.
To more easily add support for different display controller blocks, the
display controller specific bits are split out into a "kms" module,
which provides the kms plane/crtc/encoder objects.
The external HDMI, DSI, etc. blocks are part encoder, and part connector
currently. But I think I will pull in the drm_bridge patches from
chromeos tree, and split them into a bridge+connector, with the
registers that need to be set in modeset handled by the bridge. This
would remove the 'msm_connector' base class. But some things need to be
double checked to make sure I could get the correct ON/OFF sequencing..
This patch adds support for mdp4 crtc (including hw cursor), dtv encoder
(part of MDP4 block), and hdmi.
Signed-off-by: Rob Clark <robdclark@gmail.com>
2013-06-26 16:44:06 +00:00
|
|
|
|
2013-08-30 17:02:15 +00:00
|
|
|
drm_connector_init(hdmi->dev, connector, &hdmi_connector_funcs,
|
drm/msm: basic KMS driver for snapdragon
The snapdragon chips have multiple different display controllers,
depending on which chip variant/version. (As far as I can tell, current
devices have either MDP3 or MDP4, and upcoming devices have MDSS.) And
then external to the display controller are HDMI, DSI, etc. blocks which
may be shared across devices which have different display controller
blocks.
To more easily add support for different display controller blocks, the
display controller specific bits are split out into a "kms" module,
which provides the kms plane/crtc/encoder objects.
The external HDMI, DSI, etc. blocks are part encoder, and part connector
currently. But I think I will pull in the drm_bridge patches from
chromeos tree, and split them into a bridge+connector, with the
registers that need to be set in modeset handled by the bridge. This
would remove the 'msm_connector' base class. But some things need to be
double checked to make sure I could get the correct ON/OFF sequencing..
This patch adds support for mdp4 crtc (including hw cursor), dtv encoder
(part of MDP4 block), and hdmi.
Signed-off-by: Rob Clark <robdclark@gmail.com>
2013-06-26 16:44:06 +00:00
|
|
|
DRM_MODE_CONNECTOR_HDMIA);
|
|
|
|
drm_connector_helper_add(connector, &hdmi_connector_helper_funcs);
|
|
|
|
|
|
|
|
connector->polled = DRM_CONNECTOR_POLL_HPD;
|
|
|
|
|
|
|
|
connector->interlace_allowed = 1;
|
|
|
|
connector->doublescan_allowed = 0;
|
|
|
|
|
|
|
|
drm_sysfs_connector_add(connector);
|
|
|
|
|
|
|
|
ret = hpd_enable(hdmi_connector);
|
|
|
|
if (ret) {
|
2013-08-30 17:02:15 +00:00
|
|
|
dev_err(hdmi->dev->dev, "failed to enable HPD: %d\n", ret);
|
drm/msm: basic KMS driver for snapdragon
The snapdragon chips have multiple different display controllers,
depending on which chip variant/version. (As far as I can tell, current
devices have either MDP3 or MDP4, and upcoming devices have MDSS.) And
then external to the display controller are HDMI, DSI, etc. blocks which
may be shared across devices which have different display controller
blocks.
To more easily add support for different display controller blocks, the
display controller specific bits are split out into a "kms" module,
which provides the kms plane/crtc/encoder objects.
The external HDMI, DSI, etc. blocks are part encoder, and part connector
currently. But I think I will pull in the drm_bridge patches from
chromeos tree, and split them into a bridge+connector, with the
registers that need to be set in modeset handled by the bridge. This
would remove the 'msm_connector' base class. But some things need to be
double checked to make sure I could get the correct ON/OFF sequencing..
This patch adds support for mdp4 crtc (including hw cursor), dtv encoder
(part of MDP4 block), and hdmi.
Signed-off-by: Rob Clark <robdclark@gmail.com>
2013-06-26 16:44:06 +00:00
|
|
|
goto fail;
|
|
|
|
}
|
|
|
|
|
2013-08-30 17:02:15 +00:00
|
|
|
drm_mode_connector_attach_encoder(connector, hdmi->encoder);
|
drm/msm: basic KMS driver for snapdragon
The snapdragon chips have multiple different display controllers,
depending on which chip variant/version. (As far as I can tell, current
devices have either MDP3 or MDP4, and upcoming devices have MDSS.) And
then external to the display controller are HDMI, DSI, etc. blocks which
may be shared across devices which have different display controller
blocks.
To more easily add support for different display controller blocks, the
display controller specific bits are split out into a "kms" module,
which provides the kms plane/crtc/encoder objects.
The external HDMI, DSI, etc. blocks are part encoder, and part connector
currently. But I think I will pull in the drm_bridge patches from
chromeos tree, and split them into a bridge+connector, with the
registers that need to be set in modeset handled by the bridge. This
would remove the 'msm_connector' base class. But some things need to be
double checked to make sure I could get the correct ON/OFF sequencing..
This patch adds support for mdp4 crtc (including hw cursor), dtv encoder
(part of MDP4 block), and hdmi.
Signed-off-by: Rob Clark <robdclark@gmail.com>
2013-06-26 16:44:06 +00:00
|
|
|
|
|
|
|
return connector;
|
|
|
|
|
|
|
|
fail:
|
|
|
|
if (connector)
|
|
|
|
hdmi_connector_destroy(connector);
|
|
|
|
|
|
|
|
return ERR_PTR(ret);
|
|
|
|
}
|