forked from ~ljy/RK356X_SDK_RELEASE

hc
2024-05-11 04dd17822334871b23ea2862f7798fb0e0007777
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;
....@@ -926,7 +934,7 @@
926934 DRM_DEBUG_DRIVER("\n");
927935
928936 /* Copy the drm display mode in the connector local structure */
929
- memcpy(&hdmi->mode, mode, sizeof(struct drm_display_mode));
937
+ drm_mode_copy(&hdmi->mode, mode);
930938
931939 /* Update clock framerate according to the selected mode */
932940 ret = clk_set_rate(hdmi->clk_pix, mode->clock * 1000);
....@@ -989,8 +997,9 @@
989997
990998 #define CLK_TOLERANCE_HZ 50
991999
992
-static int sti_hdmi_connector_mode_valid(struct drm_connector *connector,
993
- struct drm_display_mode *mode)
1000
+static enum drm_mode_status
1001
+sti_hdmi_connector_mode_valid(struct drm_connector *connector,
1002
+ struct drm_display_mode *mode)
9941003 {
9951004 int target = mode->clock * 1000;
9961005 int target_min = target - CLK_TOLERANCE_HZ;
....@@ -1105,10 +1114,7 @@
11051114 = to_sti_hdmi_connector(connector);
11061115 struct sti_hdmi *hdmi = hdmi_connector->hdmi;
11071116
1108
- if (hdmi_debugfs_init(hdmi, hdmi->drm_dev->primary)) {
1109
- DRM_ERROR("HDMI debugfs setup failed\n");
1110
- return -EINVAL;
1111
- }
1117
+ hdmi_debugfs_init(hdmi, hdmi->drm_dev->primary);
11121118
11131119 return 0;
11141120 }
....@@ -1186,7 +1192,8 @@
11861192 return 0;
11871193 }
11881194
1189
-static int hdmi_audio_digital_mute(struct device *dev, void *data, bool enable)
1195
+static int hdmi_audio_mute(struct device *dev, void *data,
1196
+ bool enable, int direction)
11901197 {
11911198 struct sti_hdmi *hdmi = dev_get_drvdata(dev);
11921199
....@@ -1214,8 +1221,9 @@
12141221 static const struct hdmi_codec_ops audio_codec_ops = {
12151222 .hw_params = hdmi_audio_hw_params,
12161223 .audio_shutdown = hdmi_audio_shutdown,
1217
- .digital_mute = hdmi_audio_digital_mute,
1224
+ .mute_stream = hdmi_audio_mute,
12181225 .get_eld = hdmi_audio_get_eld,
1226
+ .no_capture_mute = 1,
12191227 };
12201228
12211229 static int sti_hdmi_register_audio_driver(struct device *dev,
....@@ -1249,6 +1257,7 @@
12491257 struct drm_device *drm_dev = data;
12501258 struct drm_encoder *encoder;
12511259 struct sti_hdmi_connector *connector;
1260
+ struct cec_connector_info conn_info;
12521261 struct drm_connector *drm_connector;
12531262 struct drm_bridge *bridge;
12541263 int err;
....@@ -1272,7 +1281,7 @@
12721281
12731282 bridge->driver_private = hdmi;
12741283 bridge->funcs = &sti_hdmi_bridge_funcs;
1275
- drm_bridge_attach(encoder, bridge, NULL);
1284
+ drm_bridge_attach(encoder, bridge, NULL, 0);
12761285
12771286 connector->encoder = encoder;
12781287
....@@ -1280,8 +1289,10 @@
12801289
12811290 drm_connector->polled = DRM_CONNECTOR_POLL_HPD;
12821291
1283
- drm_connector_init(drm_dev, drm_connector,
1284
- &sti_hdmi_connector_funcs, DRM_MODE_CONNECTOR_HDMIA);
1292
+ drm_connector_init_with_ddc(drm_dev, drm_connector,
1293
+ &sti_hdmi_connector_funcs,
1294
+ DRM_MODE_CONNECTOR_HDMIA,
1295
+ hdmi->ddc_adapt);
12851296 drm_connector_helper_add(drm_connector,
12861297 &sti_hdmi_connector_helper_funcs);
12871298
....@@ -1309,6 +1320,14 @@
13091320 goto err_sysfs;
13101321 }
13111322
1323
+ cec_fill_conn_info_from_drm(&conn_info, drm_connector);
1324
+ hdmi->notifier = cec_notifier_conn_register(&hdmi->dev, NULL,
1325
+ &conn_info);
1326
+ if (!hdmi->notifier) {
1327
+ hdmi->drm_connector = NULL;
1328
+ return -ENOMEM;
1329
+ }
1330
+
13121331 /* Enable default interrupts */
13131332 hdmi_write(hdmi, HDMI_DEFAULT_INT, HDMI_INT_EN);
13141333
....@@ -1322,6 +1341,9 @@
13221341 static void sti_hdmi_unbind(struct device *dev,
13231342 struct device *master, void *data)
13241343 {
1344
+ struct sti_hdmi *hdmi = dev_get_drvdata(dev);
1345
+
1346
+ cec_notifier_conn_unregister(hdmi->notifier);
13251347 }
13261348
13271349 static const struct component_ops sti_hdmi_ops = {
....@@ -1371,7 +1393,7 @@
13711393 ret = -ENOMEM;
13721394 goto release_adapter;
13731395 }
1374
- hdmi->regs = devm_ioremap_nocache(dev, res->start, resource_size(res));
1396
+ hdmi->regs = devm_ioremap(dev, res->start, resource_size(res));
13751397 if (!hdmi->regs) {
13761398 ret = -ENOMEM;
13771399 goto release_adapter;
....@@ -1427,10 +1449,6 @@
14271449 goto release_adapter;
14281450 }
14291451
1430
- hdmi->notifier = cec_notifier_get(&pdev->dev);
1431
- if (!hdmi->notifier)
1432
- goto release_adapter;
1433
-
14341452 hdmi->reset = devm_reset_control_get(dev, "hdmi");
14351453 /* Take hdmi out of reset */
14361454 if (!IS_ERR(hdmi->reset))
....@@ -1450,14 +1468,11 @@
14501468 {
14511469 struct sti_hdmi *hdmi = dev_get_drvdata(&pdev->dev);
14521470
1453
- cec_notifier_set_phys_addr(hdmi->notifier, CEC_PHYS_ADDR_INVALID);
1454
-
14551471 i2c_put_adapter(hdmi->ddc_adapt);
14561472 if (hdmi->audio_pdev)
14571473 platform_device_unregister(hdmi->audio_pdev);
14581474 component_del(&pdev->dev, &sti_hdmi_ops);
14591475
1460
- cec_notifier_put(hdmi->notifier);
14611476 return 0;
14621477 }
14631478