mdss: display-port: add support for audio programming

Add support to configure audio baud rate for
display port.

CRs-Fixed: 1009284
Change-Id: Iab3c9d578cf398f57d3151a5c895c4a09ddb3dd2
Signed-off-by: Chandan Uddaraju <chandanu@codeaurora.org>
Signed-off-by: Tatenda Chipeperekwa <tatendac@codeaurora.org>
This commit is contained in:
Chandan Uddaraju 2016-04-20 12:13:30 -07:00 committed by Tatenda Chipeperekwa
parent fdae3117e0
commit 79f9bdf53b
4 changed files with 374 additions and 29 deletions

View file

@ -29,6 +29,7 @@
#include <linux/clk.h>
#include <linux/spinlock_types.h>
#include <linux/kthread.h>
#include <linux/msm_ext_display.h>
#include "mdss.h"
#include "mdss_dp.h"
@ -827,6 +828,112 @@ int mdss_dp_wait4train(struct mdss_dp_drv_pdata *dp_drv)
return ret;
}
static int dp_get_cable_status(struct platform_device *pdev, u32 vote)
{
struct mdss_dp_drv_pdata *dp_ctrl = platform_get_drvdata(pdev);
u32 hpd;
if (!dp_ctrl) {
DEV_ERR("%s: invalid input\n", __func__);
return -ENODEV;
}
mutex_lock(&dp_ctrl->pd_msg_mutex);
hpd = dp_ctrl->cable_connected;
mutex_unlock(&dp_ctrl->pd_msg_mutex);
return hpd;
}
static int dp_audio_info_setup(struct platform_device *pdev,
struct msm_ext_disp_audio_setup_params *params)
{
int rc = 0;
struct mdss_dp_drv_pdata *dp_ctrl = platform_get_drvdata(pdev);
if (!dp_ctrl || !params) {
DEV_ERR("%s: invalid input\n", __func__);
return -ENODEV;
}
mdss_dp_audio_enable(&dp_ctrl->ctrl_io, true);
mdss_dp_config_audio_acr_ctrl(&dp_ctrl->ctrl_io,
dp_ctrl->link_rate);
mdss_dp_audio_setup_sdps(&dp_ctrl->ctrl_io);
return rc;
} /* dp_audio_info_setup */
static int dp_get_audio_edid_blk(struct platform_device *pdev,
struct msm_ext_disp_audio_edid_blk *blk)
{
struct mdss_dp_drv_pdata *dp = platform_get_drvdata(pdev);
int rc = 0;
if (!dp) {
DEV_ERR("%s: invalid input\n", __func__);
return -ENODEV;
}
rc = hdmi_edid_get_audio_blk
(dp->panel_data.panel_info.edid_data, blk);
if (rc)
DEV_ERR("%s:edid_get_audio_blk failed\n", __func__);
return rc;
} /* dp_get_audio_edid_blk */
static int mdss_dp_init_ext_disp(struct mdss_dp_drv_pdata *dp)
{
int ret = 0;
struct device_node *pd_np;
const char *phandle = "qcom,msm_ext_disp";
if (!dp) {
pr_err("%s: invalid input\n", __func__);
ret = -ENODEV;
goto end;
}
dp->ext_audio_data.type = EXT_DISPLAY_TYPE_DP;
dp->ext_audio_data.kobj = dp->kobj;
dp->ext_audio_data.pdev = dp->pdev;
dp->ext_audio_data.codec_ops.audio_info_setup =
dp_audio_info_setup;
dp->ext_audio_data.codec_ops.get_audio_edid_blk =
dp_get_audio_edid_blk;
dp->ext_audio_data.codec_ops.cable_status =
dp_get_cable_status;
if (!dp->pdev->dev.of_node) {
pr_err("%s cannot find dp dev.of_node\n", __func__);
ret = -ENODEV;
goto end;
}
pd_np = of_parse_phandle(dp->pdev->dev.of_node, phandle, 0);
if (!pd_np) {
pr_err("%s cannot find %s dev\n", __func__, phandle);
ret = -ENODEV;
goto end;
}
dp->ext_pdev = of_find_device_by_node(pd_np);
if (!dp->ext_pdev) {
pr_err("%s cannot find %s pdev\n", __func__, phandle);
ret = -ENODEV;
goto end;
}
ret = msm_ext_disp_register_intf(dp->ext_pdev,
&dp->ext_audio_data);
if (ret)
pr_err("%s: failed to register disp\n", __func__);
end:
return ret;
}
#define DEFAULT_VIDEO_RESOLUTION HDMI_VFRMT_640x480p60_4_3
static int dp_init_panel_info(struct mdss_dp_drv_pdata *dp_drv, u32 vic)
@ -1036,42 +1143,26 @@ int mdss_dp_off(struct mdss_panel_data *pdata)
return 0;
}
static inline void mdss_dp_set_audio_switch_node(
struct mdss_dp_drv_pdata *dp, int val)
{
if (dp && dp->ext_audio_data.intf_ops.notify)
dp->ext_audio_data.intf_ops.notify(dp->ext_pdev,
val);
}
static void mdss_dp_send_cable_notification(
struct mdss_dp_drv_pdata *dp, int val)
{
int state = 0;
if (!dp) {
DEV_ERR("%s: invalid input\n", __func__);
return;
}
state = dp->sdev.state;
switch_set_state(&dp->sdev, val);
DEV_INFO("%s: cable state %s %d\n", __func__,
dp->sdev.state == state ?
"is same" : "switched to",
dp->sdev.state);
}
static int mdss_dp_register_switch_event(struct mdss_dp_drv_pdata *dp)
{
int rc = -EINVAL;
if (!dp) {
DEV_ERR("%s: invalid input\n", __func__);
goto end;
}
dp->sdev.name = "hdmi";
rc = switch_dev_register(&dp->sdev);
if (rc) {
DEV_ERR("%s: display switch registration failed\n", __func__);
goto end;
}
end:
return rc;
if (dp && dp->ext_audio_data.intf_ops.hpd)
dp->ext_audio_data.intf_ops.hpd(dp->ext_pdev,
dp->ext_audio_data.type, val);
}
static int mdss_dp_edid_init(struct mdss_panel_data *pdata)
@ -1170,7 +1261,9 @@ static int mdss_dp_host_init(struct mdss_panel_data *pdata)
}
mdss_dp_send_cable_notification(dp_drv, true);
mdss_dp_set_audio_switch_node(dp_drv, true);
dp_drv->dp_initialized = true;
return ret;
edid_error:
@ -1421,7 +1514,12 @@ static int mdss_dp_event_handler(struct mdss_panel_data *pdata,
mdss_dp_sysfs_create(dp, fbi);
mdss_dp_edid_init(pdata);
mdss_dp_hdcp_init(pdata);
mdss_dp_register_switch_event(dp);
rc = mdss_dp_init_ext_disp(dp);
if (rc)
pr_err("failed to initialize ext disp data, ret=%d\n",
rc);
break;
case MDSS_EVENT_CHECK_PARAMS:
rc = mdss_dp_check_params(dp, arg);
@ -1738,6 +1836,7 @@ static void usbpd_disconnect_callback(struct usbpd_svid_handler *hdlr)
dp_drv->cable_connected = false;
mutex_unlock(&dp_drv->pd_msg_mutex);
mdss_dp_send_cable_notification(dp_drv, false);
mdss_dp_set_audio_switch_node(dp_drv, false);
}
static void usbpd_response_callback(struct usbpd_svid_handler *hdlr, u8 cmd,
@ -1998,8 +2097,12 @@ static int mdss_dp_probe(struct platform_device *pdev)
probe_err:
iounmap(dp_drv->ctrl_io.base);
iounmap(dp_drv->phy_io.base);
if (dp_drv)
if (dp_drv) {
if (dp_drv->pd)
usbpd_unregister_svid(dp_drv->pd,
&dp_drv->svid_handler);
devm_kfree(&pdev->dev, dp_drv);
}
return ret;
}

View file

@ -333,11 +333,13 @@ struct mdss_dp_drv_pdata {
int (*on) (struct mdss_panel_data *pdata);
int (*off) (struct mdss_panel_data *pdata);
struct platform_device *pdev;
struct platform_device *ext_pdev;
struct usbpd *pd;
struct usbpd_svid_handler svid_handler;
struct dp_alt_mode alt_mode;
bool dp_initialized;
struct msm_ext_disp_init_data ext_audio_data;
struct mutex emutex;
int clk_cnt;

View file

@ -18,6 +18,13 @@
#include "mdss_dp_util.h"
#define HEADER_BYTE_2_BIT 0
#define PARITY_BYTE_2_BIT 8
#define HEADER_BYTE_1_BIT 16
#define PARITY_BYTE_1_BIT 24
#define HEADER_BYTE_3_BIT 16
#define PARITY_BYTE_3_BIT 24
struct mdss_hw mdss_dp_hw = {
.hw_ndx = MDSS_HW_EDP,
.ptr = NULL,
@ -370,3 +377,163 @@ u32 mdss_dp_usbpd_gen_config_pkt(struct mdss_dp_drv_pdata *dp)
pr_debug("DP config = 0x%x\n", config);
return config;
}
void mdss_dp_config_audio_acr_ctrl(struct dss_io_data *ctrl_io,
char link_rate)
{
u32 acr_ctrl = 0;
switch (link_rate) {
case DP_LINK_RATE_162:
acr_ctrl = 0;
break;
case DP_LINK_RATE_270:
acr_ctrl = 1;
break;
case DP_LINK_RATE_540:
acr_ctrl = 2;
break;
default:
pr_debug("Unknown link rate\n");
acr_ctrl = 1;
break;
}
writel_relaxed(acr_ctrl, ctrl_io->base + MMSS_DP_AUDIO_ACR_CTRL);
}
static void mdss_dp_audio_config_parity_settings(struct dss_io_data *ctrl_io)
{
u32 value = 0;
value = readl_relaxed(ctrl_io->base + MMSS_DP_AUDIO_STREAM_0);
/* Config header and parity byte 1 */
value |= ((0x2 << HEADER_BYTE_1_BIT)
| (0x13 << PARITY_BYTE_1_BIT));
writel_relaxed(value, ctrl_io->base + MMSS_DP_AUDIO_STREAM_0);
value = readl_relaxed(ctrl_io->base + MMSS_DP_AUDIO_STREAM_1);
/* Config header and parity byte 2 */
value |= ((0x28 << HEADER_BYTE_2_BIT)
| (0xf5 << PARITY_BYTE_2_BIT));
writel_relaxed(value, ctrl_io->base + MMSS_DP_AUDIO_STREAM_1);
value = readl_relaxed(ctrl_io->base + MMSS_DP_AUDIO_STREAM_1);
/* Config header and parity byte 3 */
value |= ((0x97 << HEADER_BYTE_3_BIT)
| (0xc2 << PARITY_BYTE_3_BIT));
writel_relaxed(value, ctrl_io->base + MMSS_DP_AUDIO_STREAM_1);
value = readl_relaxed(ctrl_io->base + MMSS_DP_AUDIO_TIMESTAMP_0);
/* Config header and parity byte 1 */
value |= ((0x1 << HEADER_BYTE_1_BIT)
| (0x98 << PARITY_BYTE_1_BIT));
writel_relaxed(value, ctrl_io->base + MMSS_DP_AUDIO_TIMESTAMP_0);
value = readl_relaxed(ctrl_io->base + MMSS_DP_AUDIO_TIMESTAMP_1);
/* Config header and parity byte 2 */
value |= ((0x17 << HEADER_BYTE_2_BIT)
| (0x60 << PARITY_BYTE_2_BIT));
writel_relaxed(value, ctrl_io->base + MMSS_DP_AUDIO_TIMESTAMP_1);
value = readl_relaxed(ctrl_io->base + MMSS_DP_AUDIO_INFOFRAME_0);
/* Config header and parity byte 1 */
value |= ((0x84 << HEADER_BYTE_1_BIT)
| (0x84 << PARITY_BYTE_1_BIT));
writel_relaxed(value, ctrl_io->base + MMSS_DP_AUDIO_INFOFRAME_0);
value = readl_relaxed(ctrl_io->base + MMSS_DP_AUDIO_INFOFRAME_1);
/* Config header and parity byte 2 */
value |= ((0xb1 << HEADER_BYTE_2_BIT)
| (0x4e << PARITY_BYTE_2_BIT));
writel_relaxed(value, ctrl_io->base + MMSS_DP_AUDIO_INFOFRAME_1);
value = readl_relaxed(ctrl_io->base +
MMSS_DP_AUDIO_COPYMANAGEMENT_0);
/* Config header and parity byte 1 */
value |= ((0x5 << HEADER_BYTE_1_BIT)
| (0xbe << PARITY_BYTE_1_BIT));
writel_relaxed(value, ctrl_io->base +
MMSS_DP_AUDIO_COPYMANAGEMENT_0);
value = readl_relaxed(ctrl_io->base +
MMSS_DP_AUDIO_COPYMANAGEMENT_1);
/* Config header and parity byte 2 */
value |= ((0x0b << HEADER_BYTE_2_BIT)
| (0xc7 << PARITY_BYTE_2_BIT));
writel_relaxed(value, ctrl_io->base +
MMSS_DP_AUDIO_COPYMANAGEMENT_1);
value = readl_relaxed(ctrl_io->base +
MMSS_DP_AUDIO_COPYMANAGEMENT_1);
/* Config header and parity byte 3 */
value |= ((0x1 << HEADER_BYTE_3_BIT)
| (0x98 << PARITY_BYTE_3_BIT));
writel_relaxed(value, ctrl_io->base +
MMSS_DP_AUDIO_COPYMANAGEMENT_1);
writel_relaxed(0x22222222, ctrl_io->base +
MMSS_DP_AUDIO_COPYMANAGEMENT_2);
writel_relaxed(0x22222222, ctrl_io->base +
MMSS_DP_AUDIO_COPYMANAGEMENT_3);
writel_relaxed(0x22222222, ctrl_io->base +
MMSS_DP_AUDIO_COPYMANAGEMENT_4);
value = readl_relaxed(ctrl_io->base + MMSS_DP_AUDIO_ISRC_0);
/* Config header and parity byte 1 */
value |= ((0x6 << HEADER_BYTE_1_BIT)
| (0x35 << PARITY_BYTE_1_BIT));
writel_relaxed(value, ctrl_io->base + MMSS_DP_AUDIO_ISRC_0);
value = readl_relaxed(ctrl_io->base + MMSS_DP_AUDIO_ISRC_1);
/* Config header and parity byte 2 */
value |= ((0x0b << HEADER_BYTE_2_BIT)
| (0xc7 << PARITY_BYTE_2_BIT));
writel_relaxed(value, ctrl_io->base + MMSS_DP_AUDIO_ISRC_1);
writel_relaxed(0x33333333, ctrl_io->base + MMSS_DP_AUDIO_ISRC_2);
writel_relaxed(0x33333333, ctrl_io->base + MMSS_DP_AUDIO_ISRC_3);
writel_relaxed(0x33333333, ctrl_io->base + MMSS_DP_AUDIO_ISRC_4);
}
void mdss_dp_audio_setup_sdps(struct dss_io_data *ctrl_io)
{
u32 sdp_cfg = 0;
u32 sdp_cfg2 = 0;
/* AUDIO_TIMESTAMP_SDP_EN */
sdp_cfg |= BIT(1);
/* AUDIO_STREAM_SDP_EN */
sdp_cfg |= BIT(2);
/* AUDIO_COPY_MANAGEMENT_SDP_EN */
sdp_cfg |= BIT(5);
/* AUDIO_ISRC_SDP_EN */
sdp_cfg |= BIT(6);
/* AUDIO_INFOFRAME_SDP_EN */
sdp_cfg |= BIT(20);
writel_relaxed(sdp_cfg, ctrl_io->base + MMSS_DP_SDP_CFG);
sdp_cfg2 = readl_relaxed(ctrl_io->base + MMSS_DP_SDP_CFG2);
/* IFRM_REGSRC -> Do not use reg values */
sdp_cfg2 &= ~BIT(0);
/* AUDIO_STREAM_HB3_REGSRC-> Do not use reg values */
sdp_cfg2 &= ~BIT(1);
writel_relaxed(sdp_cfg2, ctrl_io->base + MMSS_DP_SDP_CFG2);
mdss_dp_audio_config_parity_settings(ctrl_io);
}
void mdss_dp_audio_enable(struct dss_io_data *ctrl_io, bool enable)
{
u32 audio_ctrl = readl_relaxed(ctrl_io->base + MMSS_DP_AUDIO_CFG);
if (enable)
audio_ctrl |= BIT(0);
else
audio_ctrl &= ~BIT(0);
writel_relaxed(audio_ctrl, ctrl_io->base + MMSS_DP_AUDIO_CFG);
}

View file

@ -56,6 +56,75 @@
#define DP_MAINLINK_READY (0x00000440)
#define DP_TU (0x0000044C)
#define MMSS_DP_AUDIO_TIMING_GEN (0x00000480)
#define MMSS_DP_AUDIO_TIMING_RBR_32 (0x00000484)
#define MMSS_DP_AUDIO_TIMING_HBR_32 (0x00000488)
#define MMSS_DP_AUDIO_TIMING_RBR_44 (0x0000048C)
#define MMSS_DP_AUDIO_TIMING_HBR_44 (0x00000490)
#define MMSS_DP_AUDIO_TIMING_RBR_48 (0x00000494)
#define MMSS_DP_AUDIO_TIMING_HBR_48 (0x00000498)
#define MMSS_DP_AUDIO_CFG (0x00000600)
#define MMSS_DP_AUDIO_STATUS (0x00000604)
#define MMSS_DP_AUDIO_PKT_CTRL (0x00000608)
#define MMSS_DP_AUDIO_PKT_CTRL2 (0x0000060C)
#define MMSS_DP_AUDIO_ACR_CTRL (0x00000610)
#define MMSS_DP_AUDIO_CTRL_RESET (0x00000614)
#define MMSS_DP_SDP_CFG (0x00000628)
#define MMSS_DP_SDP_CFG2 (0x0000062C)
#define MMSS_DP_AUDIO_TIMESTAMP_0 (0x00000630)
#define MMSS_DP_AUDIO_TIMESTAMP_1 (0x00000634)
#define MMSS_DP_AUDIO_STREAM_0 (0x00000640)
#define MMSS_DP_AUDIO_STREAM_1 (0x00000644)
#define MMSS_DP_EXTENSION_0 (0x00000650)
#define MMSS_DP_EXTENSION_1 (0x00000654)
#define MMSS_DP_EXTENSION_2 (0x00000658)
#define MMSS_DP_EXTENSION_3 (0x0000065C)
#define MMSS_DP_EXTENSION_4 (0x00000660)
#define MMSS_DP_EXTENSION_5 (0x00000664)
#define MMSS_DP_EXTENSION_6 (0x00000668)
#define MMSS_DP_EXTENSION_7 (0x0000066C)
#define MMSS_DP_EXTENSION_8 (0x00000670)
#define MMSS_DP_EXTENSION_9 (0x00000674)
#define MMSS_DP_AUDIO_COPYMANAGEMENT_0 (0x00000678)
#define MMSS_DP_AUDIO_COPYMANAGEMENT_1 (0x0000067C)
#define MMSS_DP_AUDIO_COPYMANAGEMENT_2 (0x00000680)
#define MMSS_DP_AUDIO_COPYMANAGEMENT_3 (0x00000684)
#define MMSS_DP_AUDIO_COPYMANAGEMENT_4 (0x00000688)
#define MMSS_DP_AUDIO_COPYMANAGEMENT_5 (0x0000068C)
#define MMSS_DP_AUDIO_ISRC_0 (0x00000690)
#define MMSS_DP_AUDIO_ISRC_1 (0x00000694)
#define MMSS_DP_AUDIO_ISRC_2 (0x00000698)
#define MMSS_DP_AUDIO_ISRC_3 (0x0000069C)
#define MMSS_DP_AUDIO_ISRC_4 (0x000006A0)
#define MMSS_DP_AUDIO_ISRC_5 (0x000006A4)
#define MMSS_DP_AUDIO_INFOFRAME_0 (0x000006A8)
#define MMSS_DP_AUDIO_INFOFRAME_1 (0x000006B0)
#define MMSS_DP_GENERIC0_0 (0x00000700)
#define MMSS_DP_GENERIC0_1 (0x00000704)
#define MMSS_DP_GENERIC0_2 (0x00000708)
#define MMSS_DP_GENERIC0_3 (0x0000070C)
#define MMSS_DP_GENERIC0_4 (0x00000710)
#define MMSS_DP_GENERIC0_5 (0x00000714)
#define MMSS_DP_GENERIC0_6 (0x00000718)
#define MMSS_DP_GENERIC0_7 (0x0000071C)
#define MMSS_DP_GENERIC0_8 (0x00000720)
#define MMSS_DP_GENERIC0_9 (0x00000724)
#define MMSS_DP_GENERIC1_0 (0x00000728)
#define MMSS_DP_GENERIC1_1 (0x0000072C)
#define MMSS_DP_GENERIC1_2 (0x00000730)
#define MMSS_DP_GENERIC1_3 (0x00000734)
#define MMSS_DP_GENERIC1_4 (0x00000738)
#define MMSS_DP_GENERIC1_5 (0x0000073C)
#define MMSS_DP_GENERIC1_6 (0x00000740)
#define MMSS_DP_GENERIC1_7 (0x00000744)
#define MMSS_DP_GENERIC1_8 (0x00000748)
#define MMSS_DP_GENERIC1_9 (0x0000074C)
/*DP PHY Register offsets */
#define DP_PHY_REVISION_ID0 (0x00000000)
#define DP_PHY_REVISION_ID1 (0x00000004)
@ -162,5 +231,9 @@ void mdss_dp_usbpd_ext_dp_status(struct usbpd_dp_status *dp_status);
u32 mdss_dp_usbpd_gen_config_pkt(struct mdss_dp_drv_pdata *dp);
void mdss_dp_ctrl_lane_mapping(struct dss_io_data *ctrl_io,
struct lane_mapping l_map);
void mdss_dp_config_audio_acr_ctrl(struct dss_io_data *ctrl_io,
char link_rate);
void mdss_dp_audio_setup_sdps(struct dss_io_data *ctrl_io);
void mdss_dp_audio_enable(struct dss_io_data *ctrl_io, bool enable);
#endif /* __DP_UTIL_H__ */