| .. | .. |
|---|
| 1054 | 1054 | int irq_id; |
|---|
| 1055 | 1055 | struct mtk_base_afe *afe; |
|---|
| 1056 | 1056 | struct mt8173_afe_private *afe_priv; |
|---|
| 1057 | + struct snd_soc_component *comp_pcm, *comp_hdmi; |
|---|
| 1057 | 1058 | |
|---|
| 1058 | 1059 | ret = dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(33)); |
|---|
| 1059 | 1060 | if (ret) |
|---|
| .. | .. |
|---|
| 1074 | 1075 | irq_id = platform_get_irq(pdev, 0); |
|---|
| 1075 | 1076 | if (irq_id <= 0) |
|---|
| 1076 | 1077 | 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 | | - } |
|---|
| 1083 | 1078 | |
|---|
| 1084 | 1079 | afe->base_addr = devm_platform_ioremap_resource(pdev, 0); |
|---|
| 1085 | 1080 | if (IS_ERR(afe->base_addr)) |
|---|
| .. | .. |
|---|
| 1142 | 1137 | if (ret) |
|---|
| 1143 | 1138 | goto err_pm_disable; |
|---|
| 1144 | 1139 | |
|---|
| 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); |
|---|
| 1149 | 1149 | if (ret) |
|---|
| 1150 | 1150 | goto err_pm_disable; |
|---|
| 1151 | 1151 | |
|---|
| 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)); |
|---|
| 1156 | 1159 | if (ret) |
|---|
| 1157 | 1160 | 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 | + } |
|---|
| 1158 | 1190 | |
|---|
| 1159 | 1191 | dev_info(&pdev->dev, "MT8173 AFE driver initialized.\n"); |
|---|
| 1160 | 1192 | return 0; |
|---|
| 1161 | 1193 | |
|---|
| 1194 | +err_cleanup_components: |
|---|
| 1195 | + snd_soc_unregister_component(&pdev->dev); |
|---|
| 1162 | 1196 | err_pm_disable: |
|---|
| 1163 | 1197 | pm_runtime_disable(&pdev->dev); |
|---|
| 1164 | 1198 | return ret; |
|---|
| .. | .. |
|---|
| 1166 | 1200 | |
|---|
| 1167 | 1201 | static int mt8173_afe_pcm_dev_remove(struct platform_device *pdev) |
|---|
| 1168 | 1202 | { |
|---|
| 1203 | + snd_soc_unregister_component(&pdev->dev); |
|---|
| 1204 | + |
|---|
| 1169 | 1205 | pm_runtime_disable(&pdev->dev); |
|---|
| 1170 | 1206 | if (!pm_runtime_status_suspended(&pdev->dev)) |
|---|
| 1171 | 1207 | mt8173_afe_runtime_suspend(&pdev->dev); |
|---|