hc
2024-01-03 2f7c68cb55ecb7331f2381deb497c27155f32faf
kernel/sound/soc/mediatek/mt8173/mt8173-afe-pcm.c
....@@ -1054,6 +1054,7 @@
10541054 int irq_id;
10551055 struct mtk_base_afe *afe;
10561056 struct mt8173_afe_private *afe_priv;
1057
+ struct snd_soc_component *comp_pcm, *comp_hdmi;
10571058
10581059 ret = dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(33));
10591060 if (ret)
....@@ -1074,12 +1075,6 @@
10741075 irq_id = platform_get_irq(pdev, 0);
10751076 if (irq_id <= 0)
10761077 return irq_id < 0 ? irq_id : -ENXIO;
1077
- ret = devm_request_irq(afe->dev, irq_id, mt8173_afe_irq_handler,
1078
- 0, "Afe_ISR_Handle", (void *)afe);
1079
- if (ret) {
1080
- dev_err(afe->dev, "could not request_irq\n");
1081
- return ret;
1082
- }
10831078
10841079 afe->base_addr = devm_platform_ioremap_resource(pdev, 0);
10851080 if (IS_ERR(afe->base_addr))
....@@ -1142,23 +1137,62 @@
11421137 if (ret)
11431138 goto err_pm_disable;
11441139
1145
- ret = devm_snd_soc_register_component(&pdev->dev,
1146
- &mt8173_afe_pcm_dai_component,
1147
- mt8173_afe_pcm_dais,
1148
- ARRAY_SIZE(mt8173_afe_pcm_dais));
1140
+ comp_pcm = devm_kzalloc(&pdev->dev, sizeof(*comp_pcm), GFP_KERNEL);
1141
+ if (!comp_pcm) {
1142
+ ret = -ENOMEM;
1143
+ goto err_pm_disable;
1144
+ }
1145
+
1146
+ ret = snd_soc_component_initialize(comp_pcm,
1147
+ &mt8173_afe_pcm_dai_component,
1148
+ &pdev->dev);
11491149 if (ret)
11501150 goto err_pm_disable;
11511151
1152
- ret = devm_snd_soc_register_component(&pdev->dev,
1153
- &mt8173_afe_hdmi_dai_component,
1154
- mt8173_afe_hdmi_dais,
1155
- ARRAY_SIZE(mt8173_afe_hdmi_dais));
1152
+#ifdef CONFIG_DEBUG_FS
1153
+ comp_pcm->debugfs_prefix = "pcm";
1154
+#endif
1155
+
1156
+ ret = snd_soc_add_component(comp_pcm,
1157
+ mt8173_afe_pcm_dais,
1158
+ ARRAY_SIZE(mt8173_afe_pcm_dais));
11561159 if (ret)
11571160 goto err_pm_disable;
1161
+
1162
+ comp_hdmi = devm_kzalloc(&pdev->dev, sizeof(*comp_hdmi), GFP_KERNEL);
1163
+ if (!comp_hdmi) {
1164
+ ret = -ENOMEM;
1165
+ goto err_cleanup_components;
1166
+ }
1167
+
1168
+ ret = snd_soc_component_initialize(comp_hdmi,
1169
+ &mt8173_afe_hdmi_dai_component,
1170
+ &pdev->dev);
1171
+ if (ret)
1172
+ goto err_cleanup_components;
1173
+
1174
+#ifdef CONFIG_DEBUG_FS
1175
+ comp_hdmi->debugfs_prefix = "hdmi";
1176
+#endif
1177
+
1178
+ ret = snd_soc_add_component(comp_hdmi,
1179
+ mt8173_afe_hdmi_dais,
1180
+ ARRAY_SIZE(mt8173_afe_hdmi_dais));
1181
+ if (ret)
1182
+ goto err_cleanup_components;
1183
+
1184
+ ret = devm_request_irq(afe->dev, irq_id, mt8173_afe_irq_handler,
1185
+ 0, "Afe_ISR_Handle", (void *)afe);
1186
+ if (ret) {
1187
+ dev_err(afe->dev, "could not request_irq\n");
1188
+ goto err_cleanup_components;
1189
+ }
11581190
11591191 dev_info(&pdev->dev, "MT8173 AFE driver initialized.\n");
11601192 return 0;
11611193
1194
+err_cleanup_components:
1195
+ snd_soc_unregister_component(&pdev->dev);
11621196 err_pm_disable:
11631197 pm_runtime_disable(&pdev->dev);
11641198 return ret;
....@@ -1166,6 +1200,8 @@
11661200
11671201 static int mt8173_afe_pcm_dev_remove(struct platform_device *pdev)
11681202 {
1203
+ snd_soc_unregister_component(&pdev->dev);
1204
+
11691205 pm_runtime_disable(&pdev->dev);
11701206 if (!pm_runtime_status_suspended(&pdev->dev))
11711207 mt8173_afe_runtime_suspend(&pdev->dev);