forked from ~ljy/RK356X_SDK_RELEASE

hc
2024-01-04 1543e317f1da31b75942316931e8f491a8920811
kernel/drivers/gpu/drm/bridge/synopsys/dw-hdmi.c
....@@ -422,14 +422,18 @@
422422
423423 if (hdmi->bridge.dev) {
424424 bool change;
425
+ void *data = hdmi->plat_data->phy_data;
425426
426427 change = drm_helper_hpd_irq_event(hdmi->bridge.dev);
427428
428
- if (change && hdmi->cec_adap &&
429
- hdmi->cec_adap->devnode.registered)
430
- cec_queue_pin_hpd_event(hdmi->cec_adap,
431
- hdmi->hpd_state,
432
- ktime_get());
429
+ if (change) {
430
+ if (hdmi->plat_data->set_ddc_io)
431
+ hdmi->plat_data->set_ddc_io(data, hdmi->hpd_state);
432
+ if (hdmi->cec_adap->devnode.registered)
433
+ cec_queue_pin_hpd_event(hdmi->cec_adap,
434
+ hdmi->hpd_state,
435
+ ktime_get());
436
+ }
433437 drm_bridge_hpd_notify(&hdmi->bridge, status);
434438 }
435439 }
....@@ -535,10 +539,12 @@
535539 hdmi_writeb(hdmi, HDMI_IH_I2CM_STAT0_ERROR | HDMI_IH_I2CM_STAT0_DONE,
536540 HDMI_IH_MUTE_I2CM_STAT0);
537541
538
- /* set SDA high level holding time */
539
- hdmi_writeb(hdmi, 0x48, HDMI_I2CM_SDA_HOLD);
540
-
541
- dw_hdmi_i2c_set_divs(hdmi);
542
+ /* Only configure when we use the internal I2C controller */
543
+ if (hdmi->i2c) {
544
+ /* set SDA high level holding time */
545
+ hdmi_writeb(hdmi, 0x48, HDMI_I2CM_SDA_HOLD);
546
+ dw_hdmi_i2c_set_divs(hdmi);
547
+ }
542548 }
543549
544550 static bool dw_hdmi_i2c_unwedge(struct dw_hdmi *hdmi)
....@@ -643,11 +649,7 @@
643649
644650 while (retry > 0) {
645651 if (!(hdmi_readb(hdmi, HDMI_PHY_STAT0) & HDMI_PHY_HPD)) {
646
- void *data = hdmi->plat_data->phy_data;
647
-
648652 dev_dbg(hdmi->dev, "hdmi disconnect, stop ddc read\n");
649
- if (hdmi->plat_data->set_ddc_io)
650
- hdmi->plat_data->set_ddc_io(data, false);
651653 return -EPERM;
652654 }
653655
....@@ -726,11 +728,7 @@
726728
727729 while (retry > 0) {
728730 if (!(hdmi_readb(hdmi, HDMI_PHY_STAT0) & HDMI_PHY_HPD)) {
729
- void *data = hdmi->plat_data->phy_data;
730
-
731731 dev_dbg(hdmi->dev, "hdmi disconnect, stop ddc write\n");
732
- if (hdmi->plat_data->set_ddc_io)
733
- hdmi->plat_data->set_ddc_io(data, false);
734732 return -EPERM;
735733 }
736734
....@@ -775,7 +773,6 @@
775773 struct dw_hdmi *hdmi = i2c_get_adapdata(adap);
776774 struct dw_hdmi_i2c *i2c = hdmi->i2c;
777775 u8 addr = msgs[0].addr;
778
- void *data = hdmi->plat_data->phy_data;
779776 int i, ret = 0;
780777
781778 if (addr == DDC_CI_ADDR)
....@@ -799,9 +796,6 @@
799796 }
800797
801798 mutex_lock(&i2c->lock);
802
-
803
- if (hdmi->plat_data->set_ddc_io)
804
- hdmi->plat_data->set_ddc_io(data, true);
805799
806800 hdmi_writeb(hdmi, 0, HDMI_I2CM_SOFTRSTZ);
807801 udelay(100);
....@@ -2328,7 +2322,7 @@
23282322
23292323 /* Dynamic Range and Mastering Infoframe is introduced in v2.11a. */
23302324 if (hdmi->version < 0x211a) {
2331
- DRM_ERROR("Not support DRM Infoframe\n");
2325
+ dev_dbg(hdmi->dev, "Not support DRM Infoframe\n");
23322326 return;
23332327 }
23342328
....@@ -2425,9 +2419,6 @@
24252419
24262420 vmode->previous_pixelclock = vmode->mpixelclock;
24272421 vmode->mpixelclock = mode->crtc_clock * 1000;
2428
- if ((mode->flags & DRM_MODE_FLAG_3D_MASK) ==
2429
- DRM_MODE_FLAG_3D_FRAME_PACKING)
2430
- vmode->mpixelclock *= 2;
24312422 dev_dbg(hdmi->dev, "final pixclk = %d\n", vmode->mpixelclock);
24322423
24332424 vmode->previous_tmdsclock = vmode->mtmdsclock;
....@@ -3093,7 +3084,6 @@
30933084 int i, ret = 0;
30943085
30953086 memset(metedata, 0, sizeof(*metedata));
3096
-#if 0
30973087 edid = dw_hdmi_get_edid(hdmi, connector);
30983088 if (edid) {
30993089 int vic = 0;
....@@ -3121,7 +3111,6 @@
31213111
31223112 kfree(edid);
31233113 } else {
3124
-#endif
31253114 hdmi->support_hdmi = true;
31263115 hdmi->sink_has_audio = true;
31273116 for (i = 0; i < ARRAY_SIZE(dw_hdmi_default_modes); i++) {
....@@ -3141,7 +3130,7 @@
31413130 info->color_formats = 0;
31423131
31433132 dev_info(hdmi->dev, "failed to get edid\n");
3144
-// }
3133
+ }
31453134 dw_hdmi_update_hdr_property(connector);
31463135 dw_hdmi_check_output_type_changed(hdmi);
31473136
....@@ -3995,7 +3984,6 @@
39953984 struct drm_bridge_state *old_state)
39963985 {
39973986 struct dw_hdmi *hdmi = bridge->driver_private;
3998
- void *data = hdmi->plat_data->phy_data;
39993987
40003988 mutex_lock(&hdmi->mutex);
40013989 hdmi->disabled = true;
....@@ -4006,11 +3994,6 @@
40063994 if (hdmi->plat_data->dclk_set)
40073995 hdmi->plat_data->dclk_set(hdmi->plat_data->phy_data, false, 0);
40083996 mutex_unlock(&hdmi->mutex);
4009
-
4010
- mutex_lock(&hdmi->i2c->lock);
4011
- if (hdmi->plat_data->set_ddc_io)
4012
- hdmi->plat_data->set_ddc_io(data, false);
4013
- mutex_unlock(&hdmi->i2c->lock);
40143997 }
40153998
40163999 static void dw_hdmi_bridge_atomic_enable(struct drm_bridge *bridge,
....@@ -4340,8 +4323,7 @@
43404323 * Even if we are using a separate i2c adapter doing this doesn't
43414324 * hurt.
43424325 */
4343
- if (hdmi->i2c)
4344
- dw_hdmi_i2c_init(hdmi);
4326
+ dw_hdmi_i2c_init(hdmi);
43454327
43464328 if (hdmi->phy.ops->setup_hpd)
43474329 hdmi->phy.ops->setup_hpd(hdmi, hdmi->phy.data);
....@@ -5010,6 +4992,7 @@
50104992 audio.get_eld = hdmi_audio_get_eld;
50114993 audio.write = hdmi_writeb;
50124994 audio.read = hdmi_readb;
4995
+ audio.mod = hdmi_modb;
50134996 hdmi->enable_audio = dw_hdmi_i2s_audio_enable;
50144997 hdmi->disable_audio = dw_hdmi_i2s_audio_disable;
50154998
....@@ -5229,8 +5212,7 @@
52295212 pinctrl_pm_select_default_state(hdmi->dev);
52305213 mutex_lock(&hdmi->mutex);
52315214 dw_hdmi_reg_initial(hdmi);
5232
- if (hdmi->i2c)
5233
- dw_hdmi_i2c_init(hdmi);
5215
+ dw_hdmi_i2c_init(hdmi);
52345216 if (hdmi->irq)
52355217 enable_irq(hdmi->irq);
52365218 /*