static int audio_info_probe(struct platform_device *pdev) { int ret; const char *string; if(NULL == pdev) { ad_loge( "huawei_audio: audio_info_probe failed, pdev is NULL\n"); return 0; } if(NULL == pdev->dev.of_node) { ad_loge( "huawei_audio: audio_info_probe failed, of_node is NULL\n"); return 0; } /* Delete ambiguous builtin mic type */ if(of_property_read_bool(pdev->dev.of_node, AUDIO_PROP_MASTER_MIC_EXIST_NODE)) { audio_property |= AUDIO_PROP_MASTER_MIC_EXIST_MASK; } else { ad_loge( "huawei_audio: check mic config, no master mic found\n"); audio_dsm_report_info(DSM_AUDIO_CARD_LOAD_FAIL_ERROR_NO, "master mic not found!"); } if(of_property_read_bool(pdev->dev.of_node, AUDIO_PROP_SECONDARY_MIC_EXIST_NODE)) { audio_property |= AUDIO_PROP_SECONDARY_MIC_EXIST_MASK; } if(of_property_read_bool(pdev->dev.of_node, AUDIO_PROP_ERROR_MIC_EXIST_NODE)) { audio_property |= AUDIO_PROP_ERROR_MIC_EXIST_MASK; } if(of_property_read_bool(pdev->dev.of_node, AUDIO_PROP_HANDHELD_MASTER_MIC_NODE)) { audio_property |= AUDIO_PROP_HANDHELD_MASTER_MIC; } if(of_property_read_bool(pdev->dev.of_node, AUDIO_PROP_HANDHELD_DUAL_MIC_NODE)) { audio_property |= AUDIO_PROP_HANDHELD_DUAL_MIC; } if(of_property_read_bool(pdev->dev.of_node, AUDIO_PROP_HANDHELD_AANC_MIC_NODE)) { audio_property |= AUDIO_PROP_HANDHELD_AANC_MIC; } if(of_property_read_bool(pdev->dev.of_node, AUDIO_PROP_LOUDSPEAKER_MASTER_MIC_NODE)) { audio_property |= AUDIO_PROP_LOUDSPEAKER_MASTER_MIC; } if(of_property_read_bool(pdev->dev.of_node, AUDIO_PROP_LOUDSPEAKER_SECOND_MIC_NODE)) { audio_property |= AUDIO_PROP_LOUDSPEAKER_SECOND_MIC; } if(of_property_read_bool(pdev->dev.of_node, AUDIO_PROP_LOUDSPEAKER_DUAL_MIC_NODE)) { audio_property |= AUDIO_PROP_LOUDSPEAKER_DUAL_MIC; } if(of_property_read_bool(pdev->dev.of_node, AUDIO_PROP_LOUDSPEAKER_ERROR_MIC_NODE)) { audio_property |= AUDIO_PROP_LOUDSPEAKER_ERROR_MIC; } string = NULL; ret = of_property_read_string(pdev->dev.of_node, PRODUCT_IDENTIFIER_NODE, &string); if(ret || (NULL == string)) { ad_loge( "huawei_audio: of_property_read_string product-identifier failed %d\n", ret); } else { memset(product_identifier, 0, sizeof(product_identifier)); strncpy(product_identifier, string, sizeof(product_identifier) - 1); } string = NULL; ret = of_property_read_string(pdev->dev.of_node, SPEAKER_PA_NODE, &string); if(ret || (NULL == string)) { ad_loge( "huawei_audio: of_property_read_string speaker-pa failed %d\n", ret); } else { memset(speaker_pa, 0, sizeof(speaker_pa)); strncpy(speaker_pa, string, sizeof(speaker_pa) - 1); } if(strcmp(speaker_pa, "tfa9895")) { ad_loge("tfa9895_flag = false\n"); tfa9895_flag = false; } else { ad_loge("tfa9895_flag = true\n"); tfa9895_flag = true; } if(false == of_property_read_bool(pdev->dev.of_node, PRODUCT_NERC_ADAPT_CONFIG)) { ad_loge( "huawei_audio: of_property_read_bool PRODUCT_NERC_ADAPT_CONFIG failed %d\n", ret); audio_property |= (AUDIO_PROP_BTSCO_NREC_ADAPT_OFF & AUDIO_PROP_BTSCO_NREC_ADAPT_MASK); } else { audio_property |= ( AUDIO_PROP_BTSCO_NREC_ADAPT_ON & AUDIO_PROP_BTSCO_NREC_ADAPT_MASK); } string = NULL; ret = of_property_read_string(pdev->dev.of_node, AUD_PARAM_VER_NODE, &string); if(ret || (NULL == string)) { ad_loge( "huawei_audio: of_property_read_string aud_param_ver failed %d\n", ret); } else { memset(aud_param_ver, 0, sizeof(aud_param_ver)); strncpy(aud_param_ver, string, sizeof(aud_param_ver) - 1); } return 0; }
static int audio_info_probe(struct platform_device *pdev) { int ret; const char *string; struct pinctrl *pinctrl; if(NULL == pdev) { printk(KERN_ERR "huawei_audio: audio_info_probe failed, pdev is NULL\n"); return 0; } if(NULL == pdev->dev.of_node) { printk(KERN_ERR "huawei_audio: audio_info_probe failed, of_node is NULL\n"); return 0; } /* Delete ambiguous builtin mic type */ if(of_property_read_bool(pdev->dev.of_node, AUDIO_PROP_MASTER_MIC_EXIST_NODE)) { audio_property |= AUDIO_PROP_MASTER_MIC_EXIST_MASK; } else { printk(KERN_ERR "huawei_audio: check mic config, no master mic found\n"); audio_dsm_report_info(DSM_AUDIO_CARD_LOAD_FAIL_ERROR_NO, "master mic not found!"); } if(of_property_read_bool(pdev->dev.of_node, AUDIO_PROP_SECONDARY_MIC_EXIST_NODE)) { audio_property |= AUDIO_PROP_SECONDARY_MIC_EXIST_MASK; } if(of_property_read_bool(pdev->dev.of_node, AUDIO_PROP_ERROR_MIC_EXIST_NODE)) { audio_property |= AUDIO_PROP_ERROR_MIC_EXIST_MASK; } if(of_property_read_bool(pdev->dev.of_node, AUDIO_PROP_HANDHELD_MASTER_MIC_NODE)) { audio_property |= AUDIO_PROP_HANDHELD_MASTER_MIC; } if(of_property_read_bool(pdev->dev.of_node, AUDIO_PROP_HANDHELD_DUAL_MIC_NODE)) { audio_property |= AUDIO_PROP_HANDHELD_DUAL_MIC; } if(of_property_read_bool(pdev->dev.of_node, AUDIO_PROP_HANDHELD_AANC_MIC_NODE)) { audio_property |= AUDIO_PROP_HANDHELD_AANC_MIC; } if(of_property_read_bool(pdev->dev.of_node, AUDIO_PROP_LOUDSPEAKER_MASTER_MIC_NODE)) { audio_property |= AUDIO_PROP_LOUDSPEAKER_MASTER_MIC; } if(of_property_read_bool(pdev->dev.of_node, AUDIO_PROP_LOUDSPEAKER_SECOND_MIC_NODE)) { audio_property |= AUDIO_PROP_LOUDSPEAKER_SECOND_MIC; } if(of_property_read_bool(pdev->dev.of_node, AUDIO_PROP_LOUDSPEAKER_ERROR_MIC_NODE)) { audio_property |= AUDIO_PROP_LOUDSPEAKER_ERROR_MIC; } string = NULL; ret = of_property_read_string(pdev->dev.of_node, PRODUCT_IDENTIFIER_NODE, &string); if(ret || (NULL == string)) { printk(KERN_ERR "huawei_audio: of_property_read_string product-identifier failed %d\n", ret); } else { memset(product_identifier, 0, sizeof(product_identifier)); strncpy(product_identifier, string, sizeof(product_identifier) - 1); } string = NULL; ret = of_property_read_string(pdev->dev.of_node, SPEAKER_PA_NODE, &string); if(ret || (NULL == string)) { printk("huawei_audio: of_property_read_string speaker-pa failed %d\n", ret); } else { memset(speaker_pa, 0, sizeof(speaker_pa)); strncpy(speaker_pa, string, sizeof(speaker_pa) - 1); } if(strcmp(speaker_pa, "tfa9895")) { printk("tfa9895_flag = false\n"); tfa9895_flag = false; } else { printk("tfa9895_flag = true\n"); tfa9895_flag = true; } string = NULL; ret = of_property_read_string(pdev->dev.of_node, SPEAKER_BOX_NODE, &string); if(ret || (NULL == string)) { printk("huawei_audio: of_property_read_string speaker-box failed %d\n", ret); } else { pinctrl = devm_pinctrl_get(&pdev->dev); if (IS_ERR(pinctrl)) { printk(KERN_ERR "Unable to get pinctrl handle\n"); } speaker_box = get_pa_box_id(pdev, pinctrl); printk(KERN_ERR "speaker_box = %d\n", speaker_box); memset(speaker_box_id, 0, sizeof(speaker_box_id)); if(PIN_VOLTAGE_LOW == speaker_box) { strncpy(speaker_box_id, "Goer", sizeof(speaker_pa) - 1); } else if(PIN_VOLTAGE_HIGH == speaker_box) { strncpy(speaker_box_id, "AAC", sizeof(speaker_pa) - 1); } else if(PIN_VOLTAGE_FLOAT == speaker_box) { strncpy(speaker_box_id, "Invalid", sizeof(speaker_pa) - 1); } else { strncpy(speaker_box_id, "None", sizeof(speaker_pa) - 1); } } if(false == of_property_read_bool(pdev->dev.of_node, PRODUCT_NERC_ADAPT_CONFIG)) { printk(KERN_ERR "huawei_audio: of_property_read_bool PRODUCT_NERC_ADAPT_CONFIG failed %d\n", ret); audio_property |= (AUDIO_PROP_BTSCO_NREC_ADAPT_OFF & AUDIO_PROP_BTSCO_NREC_ADAPT_MASK); } else { audio_property |= ( AUDIO_PROP_BTSCO_NREC_ADAPT_ON & AUDIO_PROP_BTSCO_NREC_ADAPT_MASK); } string = NULL; ret = of_property_read_string(pdev->dev.of_node, PA_i2C_NODE, &string); if(ret || (NULL == string)) { printk(KERN_ERR "huawei_audio: of_property_read_string pa-i2c failed %d\n", ret); } else { memset(pa_i2c, 0, sizeof(pa_i2c)); strncpy(pa_i2c, string, sizeof(pa_i2c) - 1); } string = NULL; ret = of_property_read_string(pdev->dev.of_node, AUD_PARAM_VER_NODE, &string); if(ret || (NULL == string)) { printk(KERN_ERR "huawei_audio: of_property_read_string aud_param_ver failed %d\n", ret); } else { memset(aud_param_ver, 0, sizeof(aud_param_ver)); strncpy(aud_param_ver, string, sizeof(aud_param_ver) - 1); } return 0; }