Skip to contentSkip to conversation

i2c old to new style conversion

DISCUSSION Luca Santini 2 participants 4 messages Jul 31, 2008 SuperH

lore
Share & tools
lore
#0 lore raw

Hi Manuel,
i'm trying the conversion of wm8731 driver and a attach my patch.

The problem is: the method wm8731_i2c_probe() - connected to i2c_add_driver.probe field - isn't called and alsa says "No Soundcard found".

in the old style driver the method wm8731_codec_probe() - connected to i2c_add_driver.attach_adapter field - is called during initialization by i2c_add_driver() .

How to call wm8731_i2c_probe()? Do i miss something?

#1 lore raw

(diff attached)

Hi Manuel,
i'm trying the conversion of wm8731 driver and a attach my patch.

The problem is: the method wm8731_i2c_probe() - connected to i2c_add_driver.probe field - isn't called and alsa says "No Soundcard found".

in the old style driver the method wm8731_codec_probe() - connected to i2c_add_driver.attach_adapter field - is called during initialization by i2c_add_driver() .

How to call wm8731_i2c_probe()? Do i miss something?

605,609c607,617
< static struct i2c_driver wm8731_i2c_driver;
< static struct i2c_client client_template;
<
< /* If the i2c layer weren't so broken, we could pass this kind of data
< around */
---

Quoted 11 lines

static void wm8731_deinit(struct snd_soc_device *socdev)

{
	if (socdev) {
		wm8731_dapm_event(socdev->codec, SNDRV_CTL_POWER_D3cold);
		snd_soc_free_pcms(socdev);
		snd_soc_dapm_free(socdev);
		kfree(socdev->codec->private_data);
		kfree(socdev->codec->reg_cache);
		kfree(socdev->codec);
	}
}

611c619
< static int wm8731_codec_probe(struct i2c_adapter *adap, int addr, int kind)
---

Quoted 1 line

static int wm8731_i2c_probe(struct i2c_client *client, const struct i2c_device_id * id /*SPES*/)

614d621
< struct wm8731_setup_data *setup = socdev->codec_data;
616d622
< struct i2c_client *i2c;
619,620c625
< if (addr != setup->i2c_address)
< return -ENODEV;
---
622,637d626
< client_template.adapter = adap;
< client_template.addr = addr;
<
< i2c = kmemdup(&client_template, sizeof(client_template), GFP_KERNEL);
< if (i2c == NULL) {
< kfree(codec);
< return -ENOMEM;
< }
< i2c_set_clientdata(i2c, codec);
< codec->control_data = i2c;
<
< ret = i2c_attach_client(i2c);
< if (ret < 0) {
< err("failed to attach codec at addr %x\n", addr);
< goto err;
< }
638a628,630

Quoted 3 lines
	i2c_set_clientdata(client,socdev);
	codec->control_data = client;	

640,641c632,633
< if (ret < 0) {
< err("failed to initialise WM8731\n");
---

Quoted 2 lines
	if (unlikely(ret < 0)) {
		err("failed to initialise WM8731 codec\n");

648d639
< kfree(i2c);
652c643
< static int wm8731_i2c_detach(struct i2c_client *client)
---

Quoted 1 line

static int wm8731_i2c_remove(struct i2c_client *client)

654,659c645
< struct snd_soc_codec *codec = i2c_get_clientdata(client);
< i2c_detach_client(client);
< kfree(codec->reg_cache);
< kfree(client);
< return 0;
< }
---

Quoted 1 line
	struct snd_soc_device *socdev = i2c_get_clientdata(client);

661,663c647,649
< static int wm8731_i2c_attach(struct i2c_adapter *adap) < {
< return i2c_probe(adap, &addr_data, wm8731_codec_probe);
---

Quoted 3 lines
	wm8731_deinit(socdev);

	return 0;

666d651
< /* corgi i2c codec control layer */
672,676d656
< .id = I2C_DRIVERID_WM8731,
< .attach_adapter = wm8731_i2c_attach,
< .detach_client = wm8731_i2c_detach,
< .command = NULL,
< };
678,680c658,660
< static struct i2c_client client_template = {
< .name = "WM8731",
< .driver = &wm8731_i2c_driver,
---

Quoted 3 lines
	.probe	= wm8731_i2c_probe,
	.remove	= wm8731_i2c_remove,

729,733d716
< struct snd_soc_device *socdev = platform_get_drvdata(pdev);
< struct snd_soc_codec *codec = socdev->codec;
<
< if (codec->control_data)
< wm8731_dapm_event(codec, SNDRV_CTL_POWER_D3cold);
735,736d717
< snd_soc_free_pcms(socdev);
< snd_soc_dapm_free(socdev);
740,741d720
< kfree(codec->private_data);
< kfree(codec);

#2 lore raw
In reply to Luca Santini
Quoted 11 lines · Luca Santini

(diff attached)

Hi Manuel,
i'm trying the conversion of wm8731 driver and a attach my patch.

The problem is: the method wm8731_i2c_probe() - connected to i2c_add_driver.probe field - isn't called and alsa says "No Soundcard found".

Quoted 7 lines

in the old style driver the method wm8731_codec_probe() - connected to i2c_add_driver.attach_adapter field - is called during initialization by i2c_add_driver() .

How to call wm8731_i2c_probe()? Do i miss something?

You should be sending this inquiry to the i2c list, where someone might be able to help you with i2c related problems.

#3 lore raw
In reply to Luca Santini

thanks for redirection Paul.

in the i2c list i found the solution:

in board setup init code you need to register the i2c device:

-----------------

	i2c_register_board_info(0, edosk7760_i2c_devices0,
				ARRAY_SIZE(edosk7760_i2c_devices0));

-----------------

where edosk7760_i2c_devices0 is:

-----------------

static struct i2c_board_info __initdata edosk7760_i2c_devices0[] = {
	{
		I2C_BOARD_INFO("wm8731", 0x1a), //channel 0
		.irq = 62,
	},
};

-----------------

and in the driver you need:

-----------------

static const struct i2c_device_id wm8731_id[] = {
	{ "wm8731", 0 },
	{ }
};

MODULE_DEVICE_TABLE(i2c, wm8731_id);

static struct i2c_driver wm8731_i2c_driver = {
	.driver = {
		.name = "wm8731",
		.owner = THIS_MODULE,
	},

	.probe	= wm8731_i2c_probe,
	.remove	= wm8731_i2c_remove,
	.id_table	= wm8731_id,  // <-- this field is important!
};

-----------------

it's important that i2c_device_id and I2C_BOARD_INFO name field (in my case "wm8731") are matching.

Quoted 28 lines · Paul Mundt
Quoted 11 lines · Luca Santini

(diff attached)

Hi Manuel,
i'm trying the conversion of wm8731 driver and a attach my patch.

The problem is: the method wm8731_i2c_probe() - connected to i2c_add_driver.probe field - isn't called and alsa says "No Soundcard found".

Quoted 7 lines

in the old style driver the method wm8731_codec_probe() - connected to i2c_add_driver.attach_adapter field - is called during initialization by i2c_add_driver() .

How to call wm8731_i2c_probe()? Do i miss something?

You should be sending this inquiry to the i2c list, where someone might be able to help you with i2c related problems.
--
To unsubscribe from this list: send the line "unsubscribe linux-sh" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html