diff options
-rw-r--r-- | include/sound/soc-dapm.h | 2 | ||||
-rw-r--r-- | sound/soc/codecs/wm8580.c | 108 | ||||
-rw-r--r-- | sound/soc/codecs/wm8580.h | 1 | ||||
-rw-r--r-- | sound/soc/codecs/wm8900.c | 113 | ||||
-rw-r--r-- | sound/soc/codecs/wm8900.h | 1 | ||||
-rw-r--r-- | sound/soc/soc-dapm.c | 22 |
6 files changed, 109 insertions, 138 deletions
diff --git a/include/sound/soc-dapm.h b/include/sound/soc-dapm.h index ca699a3017f3..7ee2f70ca42e 100644 --- a/include/sound/soc-dapm.h +++ b/include/sound/soc-dapm.h | |||
@@ -221,8 +221,6 @@ int snd_soc_dapm_new_controls(struct snd_soc_codec *codec, | |||
221 | int num); | 221 | int num); |
222 | 222 | ||
223 | /* dapm path setup */ | 223 | /* dapm path setup */ |
224 | int __deprecated snd_soc_dapm_connect_input(struct snd_soc_codec *codec, | ||
225 | const char *sink_name, const char *control_name, const char *src_name); | ||
226 | int snd_soc_dapm_new_widgets(struct snd_soc_codec *codec); | 224 | int snd_soc_dapm_new_widgets(struct snd_soc_codec *codec); |
227 | void snd_soc_dapm_free(struct snd_soc_device *socdev); | 225 | void snd_soc_dapm_free(struct snd_soc_device *socdev); |
228 | int snd_soc_dapm_add_routes(struct snd_soc_codec *codec, | 226 | int snd_soc_dapm_add_routes(struct snd_soc_codec *codec, |
diff --git a/sound/soc/codecs/wm8580.c b/sound/soc/codecs/wm8580.c index 627ebfb4209b..cbcd7c324ab9 100644 --- a/sound/soc/codecs/wm8580.c +++ b/sound/soc/codecs/wm8580.c | |||
@@ -900,85 +900,85 @@ static struct snd_soc_device *wm8580_socdev; | |||
900 | * low = 0x1a | 900 | * low = 0x1a |
901 | * high = 0x1b | 901 | * high = 0x1b |
902 | */ | 902 | */ |
903 | static unsigned short normal_i2c[] = { 0, I2C_CLIENT_END }; | ||
904 | 903 | ||
905 | /* Magic definition of all other variables and things */ | 904 | static int wm8580_i2c_probe(struct i2c_client *i2c, |
906 | I2C_CLIENT_INSMOD; | 905 | const struct i2c_device_id *id) |
907 | |||
908 | static struct i2c_driver wm8580_i2c_driver; | ||
909 | static struct i2c_client client_template; | ||
910 | |||
911 | static int wm8580_codec_probe(struct i2c_adapter *adap, int addr, int kind) | ||
912 | { | 906 | { |
913 | struct snd_soc_device *socdev = wm8580_socdev; | 907 | struct snd_soc_device *socdev = wm8580_socdev; |
914 | struct wm8580_setup_data *setup = socdev->codec_data; | ||
915 | struct snd_soc_codec *codec = socdev->codec; | 908 | struct snd_soc_codec *codec = socdev->codec; |
916 | struct i2c_client *i2c; | ||
917 | int ret; | 909 | int ret; |
918 | 910 | ||
919 | if (addr != setup->i2c_address) | ||
920 | return -ENODEV; | ||
921 | |||
922 | client_template.adapter = adap; | ||
923 | client_template.addr = addr; | ||
924 | |||
925 | i2c = kmemdup(&client_template, sizeof(client_template), GFP_KERNEL); | ||
926 | if (i2c == NULL) { | ||
927 | kfree(codec); | ||
928 | return -ENOMEM; | ||
929 | } | ||
930 | i2c_set_clientdata(i2c, codec); | 911 | i2c_set_clientdata(i2c, codec); |
931 | codec->control_data = i2c; | 912 | codec->control_data = i2c; |
932 | 913 | ||
933 | ret = i2c_attach_client(i2c); | ||
934 | if (ret < 0) { | ||
935 | dev_err(&i2c->dev, "failed to attach codec at addr %x\n", addr); | ||
936 | goto err; | ||
937 | } | ||
938 | |||
939 | ret = wm8580_init(socdev); | 914 | ret = wm8580_init(socdev); |
940 | if (ret < 0) { | 915 | if (ret < 0) |
941 | dev_err(&i2c->dev, "failed to initialise WM8580\n"); | 916 | dev_err(&i2c->dev, "failed to initialise WM8580\n"); |
942 | goto err; | ||
943 | } | ||
944 | |||
945 | return ret; | ||
946 | |||
947 | err: | ||
948 | kfree(codec); | ||
949 | kfree(i2c); | ||
950 | return ret; | 917 | return ret; |
951 | } | 918 | } |
952 | 919 | ||
953 | static int wm8580_i2c_detach(struct i2c_client *client) | 920 | static int wm8580_i2c_remove(struct i2c_client *client) |
954 | { | 921 | { |
955 | struct snd_soc_codec *codec = i2c_get_clientdata(client); | 922 | struct snd_soc_codec *codec = i2c_get_clientdata(client); |
956 | i2c_detach_client(client); | ||
957 | kfree(codec->reg_cache); | 923 | kfree(codec->reg_cache); |
958 | kfree(client); | ||
959 | return 0; | 924 | return 0; |
960 | } | 925 | } |
961 | 926 | ||
962 | static int wm8580_i2c_attach(struct i2c_adapter *adap) | 927 | static const struct i2c_device_id wm8580_i2c_id[] = { |
963 | { | 928 | { "wm8580", 0 }, |
964 | return i2c_probe(adap, &addr_data, wm8580_codec_probe); | 929 | { } |
965 | } | 930 | }; |
931 | MODULE_DEVICE_TABLE(i2c, wm8580_i2c_id); | ||
966 | 932 | ||
967 | /* corgi i2c codec control layer */ | ||
968 | static struct i2c_driver wm8580_i2c_driver = { | 933 | static struct i2c_driver wm8580_i2c_driver = { |
969 | .driver = { | 934 | .driver = { |
970 | .name = "WM8580 I2C Codec", | 935 | .name = "WM8580 I2C Codec", |
971 | .owner = THIS_MODULE, | 936 | .owner = THIS_MODULE, |
972 | }, | 937 | }, |
973 | .attach_adapter = wm8580_i2c_attach, | 938 | .probe = wm8580_i2c_probe, |
974 | .detach_client = wm8580_i2c_detach, | 939 | .remove = wm8580_i2c_remove, |
975 | .command = NULL, | 940 | .id_table = wm8580_i2c_id, |
976 | }; | 941 | }; |
977 | 942 | ||
978 | static struct i2c_client client_template = { | 943 | static int wm8580_add_i2c_device(struct platform_device *pdev, |
979 | .name = "WM8580", | 944 | const struct wm8580_setup_data *setup) |
980 | .driver = &wm8580_i2c_driver, | 945 | { |
981 | }; | 946 | struct i2c_board_info info; |
947 | struct i2c_adapter *adapter; | ||
948 | struct i2c_client *client; | ||
949 | int ret; | ||
950 | |||
951 | ret = i2c_add_driver(&wm8580_i2c_driver); | ||
952 | if (ret != 0) { | ||
953 | dev_err(&pdev->dev, "can't add i2c driver\n"); | ||
954 | return ret; | ||
955 | } | ||
956 | |||
957 | memset(&info, 0, sizeof(struct i2c_board_info)); | ||
958 | info.addr = setup->i2c_address; | ||
959 | strlcpy(info.type, "wm8580", I2C_NAME_SIZE); | ||
960 | |||
961 | adapter = i2c_get_adapter(setup->i2c_bus); | ||
962 | if (!adapter) { | ||
963 | dev_err(&pdev->dev, "can't get i2c adapter %d\n", | ||
964 | setup->i2c_bus); | ||
965 | goto err_driver; | ||
966 | } | ||
967 | |||
968 | client = i2c_new_device(adapter, &info); | ||
969 | i2c_put_adapter(adapter); | ||
970 | if (!client) { | ||
971 | dev_err(&pdev->dev, "can't add i2c device at 0x%x\n", | ||
972 | (unsigned int)info.addr); | ||
973 | goto err_driver; | ||
974 | } | ||
975 | |||
976 | return 0; | ||
977 | |||
978 | err_driver: | ||
979 | i2c_del_driver(&wm8580_i2c_driver); | ||
980 | return -ENODEV; | ||
981 | } | ||
982 | #endif | 982 | #endif |
983 | 983 | ||
984 | static int wm8580_probe(struct platform_device *pdev) | 984 | static int wm8580_probe(struct platform_device *pdev) |
@@ -1011,11 +1011,8 @@ static int wm8580_probe(struct platform_device *pdev) | |||
1011 | 1011 | ||
1012 | #if defined(CONFIG_I2C) || defined(CONFIG_I2C_MODULE) | 1012 | #if defined(CONFIG_I2C) || defined(CONFIG_I2C_MODULE) |
1013 | if (setup->i2c_address) { | 1013 | if (setup->i2c_address) { |
1014 | normal_i2c[0] = setup->i2c_address; | ||
1015 | codec->hw_write = (hw_write_t)i2c_master_send; | 1014 | codec->hw_write = (hw_write_t)i2c_master_send; |
1016 | ret = i2c_add_driver(&wm8580_i2c_driver); | 1015 | ret = wm8580_add_i2c_device(pdev, setup); |
1017 | if (ret != 0) | ||
1018 | printk(KERN_ERR "can't add i2c driver"); | ||
1019 | } | 1016 | } |
1020 | #else | 1017 | #else |
1021 | /* Add other interfaces here */ | 1018 | /* Add other interfaces here */ |
@@ -1034,6 +1031,7 @@ static int wm8580_remove(struct platform_device *pdev) | |||
1034 | snd_soc_free_pcms(socdev); | 1031 | snd_soc_free_pcms(socdev); |
1035 | snd_soc_dapm_free(socdev); | 1032 | snd_soc_dapm_free(socdev); |
1036 | #if defined(CONFIG_I2C) || defined(CONFIG_I2C_MODULE) | 1033 | #if defined(CONFIG_I2C) || defined(CONFIG_I2C_MODULE) |
1034 | i2c_unregister_device(codec->control_data); | ||
1037 | i2c_del_driver(&wm8580_i2c_driver); | 1035 | i2c_del_driver(&wm8580_i2c_driver); |
1038 | #endif | 1036 | #endif |
1039 | kfree(codec->private_data); | 1037 | kfree(codec->private_data); |
diff --git a/sound/soc/codecs/wm8580.h b/sound/soc/codecs/wm8580.h index 589ddaba21d7..09e4422f6f2f 100644 --- a/sound/soc/codecs/wm8580.h +++ b/sound/soc/codecs/wm8580.h | |||
@@ -29,6 +29,7 @@ | |||
29 | #define WM8580_CLKSRC_NONE 5 | 29 | #define WM8580_CLKSRC_NONE 5 |
30 | 30 | ||
31 | struct wm8580_setup_data { | 31 | struct wm8580_setup_data { |
32 | int i2c_bus; | ||
32 | unsigned short i2c_address; | 33 | unsigned short i2c_address; |
33 | }; | 34 | }; |
34 | 35 | ||
diff --git a/sound/soc/codecs/wm8900.c b/sound/soc/codecs/wm8900.c index 3b326c9b5586..de016f41e04c 100644 --- a/sound/soc/codecs/wm8900.c +++ b/sound/soc/codecs/wm8900.c | |||
@@ -1387,89 +1387,86 @@ static struct snd_soc_device *wm8900_socdev; | |||
1387 | 1387 | ||
1388 | #if defined(CONFIG_I2C) || defined(CONFIG_I2C_MODULE) | 1388 | #if defined(CONFIG_I2C) || defined(CONFIG_I2C_MODULE) |
1389 | 1389 | ||
1390 | static unsigned short normal_i2c[] = { 0, I2C_CLIENT_END }; | ||
1391 | |||
1392 | /* Magic definition of all other variables and things */ | ||
1393 | I2C_CLIENT_INSMOD; | ||
1394 | |||
1395 | static struct i2c_driver wm8900_i2c_driver; | ||
1396 | static struct i2c_client client_template; | ||
1397 | |||
1398 | /* If the i2c layer weren't so broken, we could pass this kind of data | 1390 | /* If the i2c layer weren't so broken, we could pass this kind of data |
1399 | around */ | 1391 | around */ |
1400 | static int wm8900_codec_probe(struct i2c_adapter *adap, int addr, int kind) | 1392 | static int wm8900_i2c_probe(struct i2c_client *i2c, |
1393 | const struct i2c_device_id *id) | ||
1401 | { | 1394 | { |
1402 | struct snd_soc_device *socdev = wm8900_socdev; | 1395 | struct snd_soc_device *socdev = wm8900_socdev; |
1403 | struct wm8900_setup_data *setup = socdev->codec_data; | ||
1404 | struct snd_soc_codec *codec = socdev->codec; | 1396 | struct snd_soc_codec *codec = socdev->codec; |
1405 | struct i2c_client *i2c; | ||
1406 | int ret; | 1397 | int ret; |
1407 | 1398 | ||
1408 | if (addr != setup->i2c_address) | ||
1409 | return -ENODEV; | ||
1410 | |||
1411 | dev_err(&adap->dev, "Probe on %x\n", addr); | ||
1412 | |||
1413 | client_template.adapter = adap; | ||
1414 | client_template.addr = addr; | ||
1415 | |||
1416 | i2c = kmemdup(&client_template, sizeof(client_template), GFP_KERNEL); | ||
1417 | if (i2c == NULL) { | ||
1418 | kfree(codec); | ||
1419 | return -ENOMEM; | ||
1420 | } | ||
1421 | i2c_set_clientdata(i2c, codec); | 1399 | i2c_set_clientdata(i2c, codec); |
1422 | codec->control_data = i2c; | 1400 | codec->control_data = i2c; |
1423 | 1401 | ||
1424 | ret = i2c_attach_client(i2c); | ||
1425 | if (ret < 0) { | ||
1426 | dev_err(&adap->dev, | ||
1427 | "failed to attach codec at addr %x\n", addr); | ||
1428 | goto err; | ||
1429 | } | ||
1430 | |||
1431 | ret = wm8900_init(socdev); | 1402 | ret = wm8900_init(socdev); |
1432 | if (ret < 0) { | 1403 | if (ret < 0) |
1433 | dev_err(&adap->dev, "failed to initialise WM8900\n"); | 1404 | dev_err(&i2c->dev, "failed to initialise WM8900\n"); |
1434 | goto err; | ||
1435 | } | ||
1436 | return ret; | ||
1437 | |||
1438 | err: | ||
1439 | kfree(codec); | ||
1440 | kfree(i2c); | ||
1441 | return ret; | 1405 | return ret; |
1442 | } | 1406 | } |
1443 | 1407 | ||
1444 | static int wm8900_i2c_detach(struct i2c_client *client) | 1408 | static int wm8900_i2c_remove(struct i2c_client *client) |
1445 | { | 1409 | { |
1446 | struct snd_soc_codec *codec = i2c_get_clientdata(client); | 1410 | struct snd_soc_codec *codec = i2c_get_clientdata(client); |
1447 | i2c_detach_client(client); | ||
1448 | kfree(codec->reg_cache); | 1411 | kfree(codec->reg_cache); |
1449 | kfree(client); | ||
1450 | return 0; | 1412 | return 0; |
1451 | } | 1413 | } |
1452 | 1414 | ||
1453 | static int wm8900_i2c_attach(struct i2c_adapter *adap) | 1415 | static const struct i2c_device_id wm8900_i2c_id[] = { |
1454 | { | 1416 | { "wm8900", 0 }, |
1455 | return i2c_probe(adap, &addr_data, wm8900_codec_probe); | 1417 | { } |
1456 | } | 1418 | }; |
1419 | MODULE_DEVICE_TABLE(i2c, wm8900_i2c_id); | ||
1457 | 1420 | ||
1458 | /* corgi i2c codec control layer */ | ||
1459 | static struct i2c_driver wm8900_i2c_driver = { | 1421 | static struct i2c_driver wm8900_i2c_driver = { |
1460 | .driver = { | 1422 | .driver = { |
1461 | .name = "WM8900 I2C codec", | 1423 | .name = "WM8900 I2C codec", |
1462 | .owner = THIS_MODULE, | 1424 | .owner = THIS_MODULE, |
1463 | }, | 1425 | }, |
1464 | .attach_adapter = wm8900_i2c_attach, | 1426 | .probe = wm8900_i2c_probe, |
1465 | .detach_client = wm8900_i2c_detach, | 1427 | .remove = wm8900_i2c_remove, |
1466 | .command = NULL, | 1428 | .id_table = wm8900_i2c_id, |
1467 | }; | 1429 | }; |
1468 | 1430 | ||
1469 | static struct i2c_client client_template = { | 1431 | static int wm8900_add_i2c_device(struct platform_device *pdev, |
1470 | .name = "WM8900", | 1432 | const struct wm8900_setup_data *setup) |
1471 | .driver = &wm8900_i2c_driver, | 1433 | { |
1472 | }; | 1434 | struct i2c_board_info info; |
1435 | struct i2c_adapter *adapter; | ||
1436 | struct i2c_client *client; | ||
1437 | int ret; | ||
1438 | |||
1439 | ret = i2c_add_driver(&wm8900_i2c_driver); | ||
1440 | if (ret != 0) { | ||
1441 | dev_err(&pdev->dev, "can't add i2c driver\n"); | ||
1442 | return ret; | ||
1443 | } | ||
1444 | |||
1445 | memset(&info, 0, sizeof(struct i2c_board_info)); | ||
1446 | info.addr = setup->i2c_address; | ||
1447 | strlcpy(info.type, "wm8900", I2C_NAME_SIZE); | ||
1448 | |||
1449 | adapter = i2c_get_adapter(setup->i2c_bus); | ||
1450 | if (!adapter) { | ||
1451 | dev_err(&pdev->dev, "can't get i2c adapter %d\n", | ||
1452 | setup->i2c_bus); | ||
1453 | goto err_driver; | ||
1454 | } | ||
1455 | |||
1456 | client = i2c_new_device(adapter, &info); | ||
1457 | i2c_put_adapter(adapter); | ||
1458 | if (!client) { | ||
1459 | dev_err(&pdev->dev, "can't add i2c device at 0x%x\n", | ||
1460 | (unsigned int)info.addr); | ||
1461 | goto err_driver; | ||
1462 | } | ||
1463 | |||
1464 | return 0; | ||
1465 | |||
1466 | err_driver: | ||
1467 | i2c_del_driver(&wm8900_i2c_driver); | ||
1468 | return -ENODEV; | ||
1469 | } | ||
1473 | #endif | 1470 | #endif |
1474 | 1471 | ||
1475 | static int wm8900_probe(struct platform_device *pdev) | 1472 | static int wm8900_probe(struct platform_device *pdev) |
@@ -1497,11 +1494,8 @@ static int wm8900_probe(struct platform_device *pdev) | |||
1497 | wm8900_socdev = socdev; | 1494 | wm8900_socdev = socdev; |
1498 | #if defined(CONFIG_I2C) || defined(CONFIG_I2C_MODULE) | 1495 | #if defined(CONFIG_I2C) || defined(CONFIG_I2C_MODULE) |
1499 | if (setup->i2c_address) { | 1496 | if (setup->i2c_address) { |
1500 | normal_i2c[0] = setup->i2c_address; | ||
1501 | codec->hw_write = (hw_write_t)i2c_master_send; | 1497 | codec->hw_write = (hw_write_t)i2c_master_send; |
1502 | ret = i2c_add_driver(&wm8900_i2c_driver); | 1498 | ret = wm8900_add_i2c_device(pdev, setup); |
1503 | if (ret != 0) | ||
1504 | printk(KERN_ERR "can't add i2c driver"); | ||
1505 | } | 1499 | } |
1506 | #else | 1500 | #else |
1507 | #error Non-I2C interfaces not yet supported | 1501 | #error Non-I2C interfaces not yet supported |
@@ -1521,6 +1515,7 @@ static int wm8900_remove(struct platform_device *pdev) | |||
1521 | snd_soc_free_pcms(socdev); | 1515 | snd_soc_free_pcms(socdev); |
1522 | snd_soc_dapm_free(socdev); | 1516 | snd_soc_dapm_free(socdev); |
1523 | #if defined(CONFIG_I2C) || defined(CONFIG_I2C_MODULE) | 1517 | #if defined(CONFIG_I2C) || defined(CONFIG_I2C_MODULE) |
1518 | i2c_unregister_device(codec->control_data); | ||
1524 | i2c_del_driver(&wm8900_i2c_driver); | 1519 | i2c_del_driver(&wm8900_i2c_driver); |
1525 | #endif | 1520 | #endif |
1526 | kfree(codec); | 1521 | kfree(codec); |
diff --git a/sound/soc/codecs/wm8900.h b/sound/soc/codecs/wm8900.h index ba450d99e902..2249a446ad37 100644 --- a/sound/soc/codecs/wm8900.h +++ b/sound/soc/codecs/wm8900.h | |||
@@ -55,6 +55,7 @@ | |||
55 | #define WM8900_ | 55 | #define WM8900_ |
56 | 56 | ||
57 | struct wm8900_setup_data { | 57 | struct wm8900_setup_data { |
58 | int i2c_bus; | ||
58 | unsigned short i2c_address; | 59 | unsigned short i2c_address; |
59 | }; | 60 | }; |
60 | 61 | ||
diff --git a/sound/soc/soc-dapm.c b/sound/soc/soc-dapm.c index 7351db9606e4..7e9f423f5b09 100644 --- a/sound/soc/soc-dapm.c +++ b/sound/soc/soc-dapm.c | |||
@@ -1007,28 +1007,6 @@ err: | |||
1007 | } | 1007 | } |
1008 | 1008 | ||
1009 | /** | 1009 | /** |
1010 | * snd_soc_dapm_connect_input - connect dapm widgets | ||
1011 | * @codec: audio codec | ||
1012 | * @sink: name of target widget | ||
1013 | * @control: mixer control name | ||
1014 | * @source: name of source name | ||
1015 | * | ||
1016 | * Connects 2 dapm widgets together via a named audio path. The sink is | ||
1017 | * the widget receiving the audio signal, whilst the source is the sender | ||
1018 | * of the audio signal. | ||
1019 | * | ||
1020 | * This function has been deprecated in favour of snd_soc_dapm_add_routes(). | ||
1021 | * | ||
1022 | * Returns 0 for success else error. | ||
1023 | */ | ||
1024 | int snd_soc_dapm_connect_input(struct snd_soc_codec *codec, const char *sink, | ||
1025 | const char *control, const char *source) | ||
1026 | { | ||
1027 | return snd_soc_dapm_add_route(codec, sink, control, source); | ||
1028 | } | ||
1029 | EXPORT_SYMBOL_GPL(snd_soc_dapm_connect_input); | ||
1030 | |||
1031 | /** | ||
1032 | * snd_soc_dapm_add_routes - Add routes between DAPM widgets | 1010 | * snd_soc_dapm_add_routes - Add routes between DAPM widgets |
1033 | * @codec: codec | 1011 | * @codec: codec |
1034 | * @route: audio routes | 1012 | * @route: audio routes |