Пример #1
0
static int dummy_codec_audio_probe(struct platform_device *pdev)
{
    int ret = 0;

    //printk(KERN_DEBUG "enter %s\n", __func__);
    printk("enter %s\n", __func__);

    dummy_codec_snd_pdata = pdev->dev.platform_data;
    snd_BUG_ON(!dummy_codec_snd_pdata);
    dummy_codec_snd_device = platform_device_alloc("soc-audio", -1);
    if (!dummy_codec_snd_device) {
        printk(KERN_ERR "ASoC: Platform device allocation failed\n");
        ret = -ENOMEM;
        goto err;
    }

    platform_set_drvdata(dummy_codec_snd_device, &snd_soc_dummy_codec);

    ret = platform_device_add(dummy_codec_snd_device);
    if (ret) {
        printk(KERN_ERR "ASoC: Platform device allocation failed\n");
        goto err_device_add;
    }


    dummy_codec_dev_init();

    return ret;

err_device_add:
    platform_device_put(dummy_codec_snd_device);
err:
    return ret;
}
Пример #2
0
static int dummy_codec_audio_probe(struct platform_device *pdev)
{
    int ret = 0;

    //printk(KERN_DEBUG "enter %s\n", __func__);
    printk("enter %s\n", __func__);
#ifdef CONFIG_USE_OF		
		dummy_codec_pdata = kzalloc(sizeof(struct dummy_codec_platform_data), GFP_KERNEL);
		if(!dummy_codec_pdata){
           // kfree(dummy_codec_pdata);
			return -1;
		}

		if (pdev->dev.of_node) {
            np = pdev->dev.of_node;
            ret = of_property_match_string(np,"status","okay");
            if(ret){
                printk("the platform not register this codec\n");
				goto err1;
            }
		}
		dummy_codec_dev=&pdev->dev;		
    dummy_codec_pdata->device_init = &dummy_codec_device_init;
    dummy_codec_pdata->device_uninit = &dummy_codec_device_deinit;
         
		pdev->dev.platform_data = dummy_codec_pdata;
#endif

    dummy_codec_snd_pdata = pdev->dev.platform_data;
    snd_BUG_ON(!dummy_codec_snd_pdata);
    dummy_codec_snd_device = platform_device_alloc("soc-audio", -1);
    if (!dummy_codec_snd_device) {
        printk(KERN_ERR "ASoC: Platform device allocation failed\n");
        ret = -ENOMEM;
        goto err;
    }

    platform_set_drvdata(dummy_codec_snd_device, &snd_soc_dummy_codec);

    ret = platform_device_add(dummy_codec_snd_device);
    if (ret) {
        printk(KERN_ERR "ASoC: Platform device allocation failed\n");
        goto err_device_add;
    }


    dummy_codec_dev_init();

    return ret;

err_device_add:
    platform_device_put(dummy_codec_snd_device);
err:
err1:
    kfree(dummy_codec_pdata);
    return ret;
}
static int dummy_codec_audio_probe(struct platform_device *pdev)
{
    int ret = 0;
		struct snd_soc_card *card = &snd_soc_dummy_codec;

    //printk(KERN_DEBUG "enter %s\n", __func__);
    printk("enter %s\n", __func__);
#ifdef CONFIG_USE_OF
		dummy_codec_pdata = kzalloc(sizeof(struct dummy_codec_platform_data), GFP_KERNEL);
		if(!dummy_codec_pdata){
           // kfree(dummy_codec_pdata);
			return -1;
		}

		if (pdev->dev.of_node) {
            np = pdev->dev.of_node;
            ret = of_property_match_string(np,"status","okay");
            if(ret){
                printk("the platform not register this codec\n");
				goto err1;
            }
		}
		dummy_codec_dev=&pdev->dev;
    dummy_codec_pdata->device_init = &dummy_codec_device_init;
    dummy_codec_pdata->device_uninit = &dummy_codec_device_deinit;

		pdev->dev.platform_data = dummy_codec_pdata;
		dummy_codec_snd_pdata = pdev->dev.platform_data;
#endif

#if 1
    card->dev = &pdev->dev;
		platform_set_drvdata(pdev, card);
		snd_soc_card_set_drvdata(card, dummy_codec_pdata);
		if (!(pdev->dev.of_node)) {
			dev_err(&pdev->dev, "Must be instantiated using device tree\n");
			ret = -EINVAL;
			goto err;
		}

    ret = snd_soc_register_card(card);
		if (ret) {
			dev_err(&pdev->dev, "snd_soc_register_card failed (%d)\n",
			ret);
		goto err;
	}

#endif
#if 0
    dummy_codec_snd_pdata = pdev->dev.platform_data;
    snd_BUG_ON(!dummy_codec_snd_pdata);
    dummy_codec_snd_device = platform_device_alloc("soc-audio", -1);
    if (!dummy_codec_snd_device) {
        printk(KERN_ERR "ASoC: Platform device allocation failed\n");
        ret = -ENOMEM;
        goto err;
    }

    platform_set_drvdata(dummy_codec_snd_device, &snd_soc_dummy_codec);

    ret = platform_device_add(dummy_codec_snd_device);
    if (ret) {
        printk(KERN_ERR "ASoC: Platform device allocation failed\n");
        goto err_device_add;
    }
#endif

    dummy_codec_dev_init();

    return ret;

#if 0
err_device_add:
    platform_device_put(dummy_codec_snd_device);
#endif
err:
err1:
    kfree(dummy_codec_pdata);
    return ret;
}