forked from ~ljy/RK356X_SDK_RELEASE

hc
2023-12-09 95099d4622f8cb224d94e314c7a8e0df60b13f87
kernel/drivers/gpu/drm/sti/sti_hdmi.c
....@@ -9,14 +9,18 @@
99 #include <linux/debugfs.h>
1010 #include <linux/hdmi.h>
1111 #include <linux/module.h>
12
-#include <linux/of_gpio.h>
12
+#include <linux/io.h>
1313 #include <linux/platform_device.h>
1414 #include <linux/reset.h>
1515
16
-#include <drm/drmP.h>
1716 #include <drm/drm_atomic_helper.h>
18
-#include <drm/drm_crtc_helper.h>
17
+#include <drm/drm_bridge.h>
18
+#include <drm/drm_debugfs.h>
19
+#include <drm/drm_drv.h>
1920 #include <drm/drm_edid.h>
21
+#include <drm/drm_file.h>
22
+#include <drm/drm_print.h>
23
+#include <drm/drm_probe_helper.h>
2024
2125 #include <sound/hdmi-codec.h>
2226
....@@ -330,7 +334,6 @@
330334 * Helper to concatenate infoframe in 32 bits word
331335 *
332336 * @ptr: pointer on the hdmi internal structure
333
- * @data: infoframe to write
334337 * @size: size to write
335338 */
336339 static inline unsigned int hdmi_infoframe_subpack(const u8 *ptr, size_t size)
....@@ -434,7 +437,8 @@
434437
435438 DRM_DEBUG_DRIVER("\n");
436439
437
- ret = drm_hdmi_avi_infoframe_from_display_mode(&infoframe, mode, false);
440
+ ret = drm_hdmi_avi_infoframe_from_display_mode(&infoframe,
441
+ hdmi->drm_connector, mode);
438442 if (ret < 0) {
439443 DRM_ERROR("failed to setup AVI infoframe: %d\n", ret);
440444 return ret;
....@@ -539,13 +543,14 @@
539543 return 0;
540544 }
541545
546
+#define HDMI_TIMEOUT_SWRESET 100 /*milliseconds */
547
+
542548 /**
543549 * Software reset of the hdmi subsystem
544550 *
545551 * @hdmi: pointer on the hdmi internal structure
546552 *
547553 */
548
-#define HDMI_TIMEOUT_SWRESET 100 /*milliseconds */
549554 static void hdmi_swreset(struct sti_hdmi *hdmi)
550555 {
551556 u32 val;
....@@ -722,16 +727,16 @@
722727 { "hdmi", hdmi_dbg_show, 0, NULL },
723728 };
724729
725
-static int hdmi_debugfs_init(struct sti_hdmi *hdmi, struct drm_minor *minor)
730
+static void hdmi_debugfs_init(struct sti_hdmi *hdmi, struct drm_minor *minor)
726731 {
727732 unsigned int i;
728733
729734 for (i = 0; i < ARRAY_SIZE(hdmi_debugfs_files); i++)
730735 hdmi_debugfs_files[i].data = hdmi;
731736
732
- return drm_debugfs_create_files(hdmi_debugfs_files,
733
- ARRAY_SIZE(hdmi_debugfs_files),
734
- minor->debugfs_root, minor);
737
+ drm_debugfs_create_files(hdmi_debugfs_files,
738
+ ARRAY_SIZE(hdmi_debugfs_files),
739
+ minor->debugfs_root, minor);
735740 }
736741
737742 static void sti_hdmi_disable(struct drm_bridge *bridge)
....@@ -845,10 +850,13 @@
845850 switch (info->channels) {
846851 case 8:
847852 audio_cfg |= HDMI_AUD_CFG_CH78_VALID;
853
+ fallthrough;
848854 case 6:
849855 audio_cfg |= HDMI_AUD_CFG_CH56_VALID;
856
+ fallthrough;
850857 case 4:
851858 audio_cfg |= HDMI_AUD_CFG_CH34_VALID | HDMI_AUD_CFG_8CH;
859
+ fallthrough;
852860 case 2:
853861 audio_cfg |= HDMI_AUD_CFG_CH12_VALID;
854862 break;
....@@ -917,8 +925,8 @@
917925 }
918926
919927 static void sti_hdmi_set_mode(struct drm_bridge *bridge,
920
- struct drm_display_mode *mode,
921
- struct drm_display_mode *adjusted_mode)
928
+ const struct drm_display_mode *mode,
929
+ const struct drm_display_mode *adjusted_mode)
922930 {
923931 struct sti_hdmi *hdmi = bridge->driver_private;
924932 int ret;
....@@ -1105,10 +1113,7 @@
11051113 = to_sti_hdmi_connector(connector);
11061114 struct sti_hdmi *hdmi = hdmi_connector->hdmi;
11071115
1108
- if (hdmi_debugfs_init(hdmi, hdmi->drm_dev->primary)) {
1109
- DRM_ERROR("HDMI debugfs setup failed\n");
1110
- return -EINVAL;
1111
- }
1116
+ hdmi_debugfs_init(hdmi, hdmi->drm_dev->primary);
11121117
11131118 return 0;
11141119 }
....@@ -1186,7 +1191,8 @@
11861191 return 0;
11871192 }
11881193
1189
-static int hdmi_audio_digital_mute(struct device *dev, void *data, bool enable)
1194
+static int hdmi_audio_mute(struct device *dev, void *data,
1195
+ bool enable, int direction)
11901196 {
11911197 struct sti_hdmi *hdmi = dev_get_drvdata(dev);
11921198
....@@ -1214,8 +1220,9 @@
12141220 static const struct hdmi_codec_ops audio_codec_ops = {
12151221 .hw_params = hdmi_audio_hw_params,
12161222 .audio_shutdown = hdmi_audio_shutdown,
1217
- .digital_mute = hdmi_audio_digital_mute,
1223
+ .mute_stream = hdmi_audio_mute,
12181224 .get_eld = hdmi_audio_get_eld,
1225
+ .no_capture_mute = 1,
12191226 };
12201227
12211228 static int sti_hdmi_register_audio_driver(struct device *dev,
....@@ -1249,6 +1256,7 @@
12491256 struct drm_device *drm_dev = data;
12501257 struct drm_encoder *encoder;
12511258 struct sti_hdmi_connector *connector;
1259
+ struct cec_connector_info conn_info;
12521260 struct drm_connector *drm_connector;
12531261 struct drm_bridge *bridge;
12541262 int err;
....@@ -1272,7 +1280,7 @@
12721280
12731281 bridge->driver_private = hdmi;
12741282 bridge->funcs = &sti_hdmi_bridge_funcs;
1275
- drm_bridge_attach(encoder, bridge, NULL);
1283
+ drm_bridge_attach(encoder, bridge, NULL, 0);
12761284
12771285 connector->encoder = encoder;
12781286
....@@ -1280,8 +1288,10 @@
12801288
12811289 drm_connector->polled = DRM_CONNECTOR_POLL_HPD;
12821290
1283
- drm_connector_init(drm_dev, drm_connector,
1284
- &sti_hdmi_connector_funcs, DRM_MODE_CONNECTOR_HDMIA);
1291
+ drm_connector_init_with_ddc(drm_dev, drm_connector,
1292
+ &sti_hdmi_connector_funcs,
1293
+ DRM_MODE_CONNECTOR_HDMIA,
1294
+ hdmi->ddc_adapt);
12851295 drm_connector_helper_add(drm_connector,
12861296 &sti_hdmi_connector_helper_funcs);
12871297
....@@ -1309,6 +1319,14 @@
13091319 goto err_sysfs;
13101320 }
13111321
1322
+ cec_fill_conn_info_from_drm(&conn_info, drm_connector);
1323
+ hdmi->notifier = cec_notifier_conn_register(&hdmi->dev, NULL,
1324
+ &conn_info);
1325
+ if (!hdmi->notifier) {
1326
+ hdmi->drm_connector = NULL;
1327
+ return -ENOMEM;
1328
+ }
1329
+
13121330 /* Enable default interrupts */
13131331 hdmi_write(hdmi, HDMI_DEFAULT_INT, HDMI_INT_EN);
13141332
....@@ -1322,6 +1340,9 @@
13221340 static void sti_hdmi_unbind(struct device *dev,
13231341 struct device *master, void *data)
13241342 {
1343
+ struct sti_hdmi *hdmi = dev_get_drvdata(dev);
1344
+
1345
+ cec_notifier_conn_unregister(hdmi->notifier);
13251346 }
13261347
13271348 static const struct component_ops sti_hdmi_ops = {
....@@ -1371,7 +1392,7 @@
13711392 ret = -ENOMEM;
13721393 goto release_adapter;
13731394 }
1374
- hdmi->regs = devm_ioremap_nocache(dev, res->start, resource_size(res));
1395
+ hdmi->regs = devm_ioremap(dev, res->start, resource_size(res));
13751396 if (!hdmi->regs) {
13761397 ret = -ENOMEM;
13771398 goto release_adapter;
....@@ -1427,10 +1448,6 @@
14271448 goto release_adapter;
14281449 }
14291450
1430
- hdmi->notifier = cec_notifier_get(&pdev->dev);
1431
- if (!hdmi->notifier)
1432
- goto release_adapter;
1433
-
14341451 hdmi->reset = devm_reset_control_get(dev, "hdmi");
14351452 /* Take hdmi out of reset */
14361453 if (!IS_ERR(hdmi->reset))
....@@ -1450,14 +1467,11 @@
14501467 {
14511468 struct sti_hdmi *hdmi = dev_get_drvdata(&pdev->dev);
14521469
1453
- cec_notifier_set_phys_addr(hdmi->notifier, CEC_PHYS_ADDR_INVALID);
1454
-
14551470 i2c_put_adapter(hdmi->ddc_adapt);
14561471 if (hdmi->audio_pdev)
14571472 platform_device_unregister(hdmi->audio_pdev);
14581473 component_del(&pdev->dev, &sti_hdmi_ops);
14591474
1460
- cec_notifier_put(hdmi->notifier);
14611475 return 0;
14621476 }
14631477