aboutsummaryrefslogtreecommitdiffstats
path: root/sound
diff options
context:
space:
mode:
Diffstat (limited to 'sound')
-rw-r--r--sound/aoa/codecs/onyx.c76
-rw-r--r--sound/aoa/codecs/tas.c66
-rw-r--r--sound/pci/atiixp.c6
-rw-r--r--sound/pci/emu10k1/io.c2
-rw-r--r--sound/pci/intel8x0.c12
-rw-r--r--sound/ppc/keywest.c82
-rw-r--r--sound/soc/codecs/wm9705.c2
-rw-r--r--sound/soc/omap/n810.c4
-rw-r--r--sound/soc/omap/omap-mcbsp.c12
-rw-r--r--sound/soc/omap/omap-mcbsp.h3
-rw-r--r--sound/soc/omap/omap-pcm.c5
-rw-r--r--sound/soc/omap/omap-pcm.h3
-rw-r--r--sound/soc/omap/osk5912.c4
-rw-r--r--sound/soc/pxa/pxa-ssp.c37
-rw-r--r--sound/soc/s3c24xx/jive_wm8750.c12
-rw-r--r--sound/soc/s3c24xx/s3c-i2s-v2.c18
-rw-r--r--sound/soc/s3c24xx/s3c2412-i2s.c2
-rw-r--r--sound/usb/usx2y/us122l.c12
-rw-r--r--sound/usb/usx2y/usb_stream.c67
19 files changed, 255 insertions, 170 deletions
diff --git a/sound/aoa/codecs/onyx.c b/sound/aoa/codecs/onyx.c
index 15500b9d2da0..84bb07d39a7f 100644
--- a/sound/aoa/codecs/onyx.c
+++ b/sound/aoa/codecs/onyx.c
@@ -47,7 +47,7 @@ MODULE_DESCRIPTION("pcm3052 (onyx) codec driver for snd-aoa");
47struct onyx { 47struct onyx {
48 /* cache registers 65 to 80, they are write-only! */ 48 /* cache registers 65 to 80, they are write-only! */
49 u8 cache[16]; 49 u8 cache[16];
50 struct i2c_client i2c; 50 struct i2c_client *i2c;
51 struct aoa_codec codec; 51 struct aoa_codec codec;
52 u32 initialised:1, 52 u32 initialised:1,
53 spdif_locked:1, 53 spdif_locked:1,
@@ -72,7 +72,7 @@ static int onyx_read_register(struct onyx *onyx, u8 reg, u8 *value)
72 *value = onyx->cache[reg-FIRSTREGISTER]; 72 *value = onyx->cache[reg-FIRSTREGISTER];
73 return 0; 73 return 0;
74 } 74 }
75 v = i2c_smbus_read_byte_data(&onyx->i2c, reg); 75 v = i2c_smbus_read_byte_data(onyx->i2c, reg);
76 if (v < 0) 76 if (v < 0)
77 return -1; 77 return -1;
78 *value = (u8)v; 78 *value = (u8)v;
@@ -84,7 +84,7 @@ static int onyx_write_register(struct onyx *onyx, u8 reg, u8 value)
84{ 84{
85 int result; 85 int result;
86 86
87 result = i2c_smbus_write_byte_data(&onyx->i2c, reg, value); 87 result = i2c_smbus_write_byte_data(onyx->i2c, reg, value);
88 if (!result) 88 if (!result)
89 onyx->cache[reg-FIRSTREGISTER] = value; 89 onyx->cache[reg-FIRSTREGISTER] = value;
90 return result; 90 return result;
@@ -996,12 +996,45 @@ static void onyx_exit_codec(struct aoa_codec *codec)
996 onyx->codec.soundbus_dev->detach_codec(onyx->codec.soundbus_dev, onyx); 996 onyx->codec.soundbus_dev->detach_codec(onyx->codec.soundbus_dev, onyx);
997} 997}
998 998
999static struct i2c_driver onyx_driver;
1000
1001static int onyx_create(struct i2c_adapter *adapter, 999static int onyx_create(struct i2c_adapter *adapter,
1002 struct device_node *node, 1000 struct device_node *node,
1003 int addr) 1001 int addr)
1004{ 1002{
1003 struct i2c_board_info info;
1004 struct i2c_client *client;
1005
1006 memset(&info, 0, sizeof(struct i2c_board_info));
1007 strlcpy(info.type, "aoa_codec_onyx", I2C_NAME_SIZE);
1008 info.addr = addr;
1009 info.platform_data = node;
1010 client = i2c_new_device(adapter, &info);
1011 if (!client)
1012 return -ENODEV;
1013
1014 /*
1015 * We know the driver is already loaded, so the device should be
1016 * already bound. If not it means binding failed, which suggests
1017 * the device doesn't really exist and should be deleted.
1018 * Ideally this would be replaced by better checks _before_
1019 * instantiating the device.
1020 */
1021 if (!client->driver) {
1022 i2c_unregister_device(client);
1023 return -ENODEV;
1024 }
1025
1026 /*
1027 * Let i2c-core delete that device on driver removal.
1028 * This is safe because i2c-core holds the core_lock mutex for us.
1029 */
1030 list_add_tail(&client->detected, &client->driver->clients);
1031 return 0;
1032}
1033
1034static int onyx_i2c_probe(struct i2c_client *client,
1035 const struct i2c_device_id *id)
1036{
1037 struct device_node *node = client->dev.platform_data;
1005 struct onyx *onyx; 1038 struct onyx *onyx;
1006 u8 dummy; 1039 u8 dummy;
1007 1040
@@ -1011,20 +1044,12 @@ static int onyx_create(struct i2c_adapter *adapter,
1011 return -ENOMEM; 1044 return -ENOMEM;
1012 1045
1013 mutex_init(&onyx->mutex); 1046 mutex_init(&onyx->mutex);
1014 onyx->i2c.driver = &onyx_driver; 1047 onyx->i2c = client;
1015 onyx->i2c.adapter = adapter; 1048 i2c_set_clientdata(client, onyx);
1016 onyx->i2c.addr = addr & 0x7f;
1017 strlcpy(onyx->i2c.name, "onyx audio codec", I2C_NAME_SIZE);
1018
1019 if (i2c_attach_client(&onyx->i2c)) {
1020 printk(KERN_ERR PFX "failed to attach to i2c\n");
1021 goto fail;
1022 }
1023 1049
1024 /* we try to read from register ONYX_REG_CONTROL 1050 /* we try to read from register ONYX_REG_CONTROL
1025 * to check if the codec is present */ 1051 * to check if the codec is present */
1026 if (onyx_read_register(onyx, ONYX_REG_CONTROL, &dummy) != 0) { 1052 if (onyx_read_register(onyx, ONYX_REG_CONTROL, &dummy) != 0) {
1027 i2c_detach_client(&onyx->i2c);
1028 printk(KERN_ERR PFX "failed to read control register\n"); 1053 printk(KERN_ERR PFX "failed to read control register\n");
1029 goto fail; 1054 goto fail;
1030 } 1055 }
@@ -1036,14 +1061,14 @@ static int onyx_create(struct i2c_adapter *adapter,
1036 onyx->codec.node = of_node_get(node); 1061 onyx->codec.node = of_node_get(node);
1037 1062
1038 if (aoa_codec_register(&onyx->codec)) { 1063 if (aoa_codec_register(&onyx->codec)) {
1039 i2c_detach_client(&onyx->i2c);
1040 goto fail; 1064 goto fail;
1041 } 1065 }
1042 printk(KERN_DEBUG PFX "created and attached onyx instance\n"); 1066 printk(KERN_DEBUG PFX "created and attached onyx instance\n");
1043 return 0; 1067 return 0;
1044 fail: 1068 fail:
1069 i2c_set_clientdata(client, NULL);
1045 kfree(onyx); 1070 kfree(onyx);
1046 return -EINVAL; 1071 return -ENODEV;
1047} 1072}
1048 1073
1049static int onyx_i2c_attach(struct i2c_adapter *adapter) 1074static int onyx_i2c_attach(struct i2c_adapter *adapter)
@@ -1080,28 +1105,33 @@ static int onyx_i2c_attach(struct i2c_adapter *adapter)
1080 return onyx_create(adapter, NULL, 0x47); 1105 return onyx_create(adapter, NULL, 0x47);
1081} 1106}
1082 1107
1083static int onyx_i2c_detach(struct i2c_client *client) 1108static int onyx_i2c_remove(struct i2c_client *client)
1084{ 1109{
1085 struct onyx *onyx = container_of(client, struct onyx, i2c); 1110 struct onyx *onyx = i2c_get_clientdata(client);
1086 int err;
1087 1111
1088 if ((err = i2c_detach_client(client)))
1089 return err;
1090 aoa_codec_unregister(&onyx->codec); 1112 aoa_codec_unregister(&onyx->codec);
1091 of_node_put(onyx->codec.node); 1113 of_node_put(onyx->codec.node);
1092 if (onyx->codec_info) 1114 if (onyx->codec_info)
1093 kfree(onyx->codec_info); 1115 kfree(onyx->codec_info);
1116 i2c_set_clientdata(client, onyx);
1094 kfree(onyx); 1117 kfree(onyx);
1095 return 0; 1118 return 0;
1096} 1119}
1097 1120
1121static const struct i2c_device_id onyx_i2c_id[] = {
1122 { "aoa_codec_onyx", 0 },
1123 { }
1124};
1125
1098static struct i2c_driver onyx_driver = { 1126static struct i2c_driver onyx_driver = {
1099 .driver = { 1127 .driver = {
1100 .name = "aoa_codec_onyx", 1128 .name = "aoa_codec_onyx",
1101 .owner = THIS_MODULE, 1129 .owner = THIS_MODULE,
1102 }, 1130 },
1103 .attach_adapter = onyx_i2c_attach, 1131 .attach_adapter = onyx_i2c_attach,
1104 .detach_client = onyx_i2c_detach, 1132 .probe = onyx_i2c_probe,
1133 .remove = onyx_i2c_remove,
1134 .id_table = onyx_i2c_id,
1105}; 1135};
1106 1136
1107static int __init onyx_init(void) 1137static int __init onyx_init(void)
diff --git a/sound/aoa/codecs/tas.c b/sound/aoa/codecs/tas.c
index 008e0f85097d..f0ebc971c686 100644
--- a/sound/aoa/codecs/tas.c
+++ b/sound/aoa/codecs/tas.c
@@ -82,7 +82,7 @@ MODULE_DESCRIPTION("tas codec driver for snd-aoa");
82 82
83struct tas { 83struct tas {
84 struct aoa_codec codec; 84 struct aoa_codec codec;
85 struct i2c_client i2c; 85 struct i2c_client *i2c;
86 u32 mute_l:1, mute_r:1 , 86 u32 mute_l:1, mute_r:1 ,
87 controls_created:1 , 87 controls_created:1 ,
88 drc_enabled:1, 88 drc_enabled:1,
@@ -108,9 +108,9 @@ static struct tas *codec_to_tas(struct aoa_codec *codec)
108static inline int tas_write_reg(struct tas *tas, u8 reg, u8 len, u8 *data) 108static inline int tas_write_reg(struct tas *tas, u8 reg, u8 len, u8 *data)
109{ 109{
110 if (len == 1) 110 if (len == 1)
111 return i2c_smbus_write_byte_data(&tas->i2c, reg, *data); 111 return i2c_smbus_write_byte_data(tas->i2c, reg, *data);
112 else 112 else
113 return i2c_smbus_write_i2c_block_data(&tas->i2c, reg, len, data); 113 return i2c_smbus_write_i2c_block_data(tas->i2c, reg, len, data);
114} 114}
115 115
116static void tas3004_set_drc(struct tas *tas) 116static void tas3004_set_drc(struct tas *tas)
@@ -882,12 +882,34 @@ static void tas_exit_codec(struct aoa_codec *codec)
882} 882}
883 883
884 884
885static struct i2c_driver tas_driver;
886
887static int tas_create(struct i2c_adapter *adapter, 885static int tas_create(struct i2c_adapter *adapter,
888 struct device_node *node, 886 struct device_node *node,
889 int addr) 887 int addr)
890{ 888{
889 struct i2c_board_info info;
890 struct i2c_client *client;
891
892 memset(&info, 0, sizeof(struct i2c_board_info));
893 strlcpy(info.type, "aoa_codec_tas", I2C_NAME_SIZE);
894 info.addr = addr;
895 info.platform_data = node;
896
897 client = i2c_new_device(adapter, &info);
898 if (!client)
899 return -ENODEV;
900
901 /*
902 * Let i2c-core delete that device on driver removal.
903 * This is safe because i2c-core holds the core_lock mutex for us.
904 */
905 list_add_tail(&client->detected, &client->driver->clients);
906 return 0;
907}
908
909static int tas_i2c_probe(struct i2c_client *client,
910 const struct i2c_device_id *id)
911{
912 struct device_node *node = client->dev.platform_data;
891 struct tas *tas; 913 struct tas *tas;
892 914
893 tas = kzalloc(sizeof(struct tas), GFP_KERNEL); 915 tas = kzalloc(sizeof(struct tas), GFP_KERNEL);
@@ -896,17 +918,11 @@ static int tas_create(struct i2c_adapter *adapter,
896 return -ENOMEM; 918 return -ENOMEM;
897 919
898 mutex_init(&tas->mtx); 920 mutex_init(&tas->mtx);
899 tas->i2c.driver = &tas_driver; 921 tas->i2c = client;
900 tas->i2c.adapter = adapter; 922 i2c_set_clientdata(client, tas);
901 tas->i2c.addr = addr; 923
902 /* seems that half is a saner default */ 924 /* seems that half is a saner default */
903 tas->drc_range = TAS3004_DRC_MAX / 2; 925 tas->drc_range = TAS3004_DRC_MAX / 2;
904 strlcpy(tas->i2c.name, "tas audio codec", I2C_NAME_SIZE);
905
906 if (i2c_attach_client(&tas->i2c)) {
907 printk(KERN_ERR PFX "failed to attach to i2c\n");
908 goto fail;
909 }
910 926
911 strlcpy(tas->codec.name, "tas", MAX_CODEC_NAME_LEN); 927 strlcpy(tas->codec.name, "tas", MAX_CODEC_NAME_LEN);
912 tas->codec.owner = THIS_MODULE; 928 tas->codec.owner = THIS_MODULE;
@@ -915,14 +931,12 @@ static int tas_create(struct i2c_adapter *adapter,
915 tas->codec.node = of_node_get(node); 931 tas->codec.node = of_node_get(node);
916 932
917 if (aoa_codec_register(&tas->codec)) { 933 if (aoa_codec_register(&tas->codec)) {
918 goto detach; 934 goto fail;
919 } 935 }
920 printk(KERN_DEBUG 936 printk(KERN_DEBUG
921 "snd-aoa-codec-tas: tas found, addr 0x%02x on %s\n", 937 "snd-aoa-codec-tas: tas found, addr 0x%02x on %s\n",
922 addr, node->full_name); 938 (unsigned int)client->addr, node->full_name);
923 return 0; 939 return 0;
924 detach:
925 i2c_detach_client(&tas->i2c);
926 fail: 940 fail:
927 mutex_destroy(&tas->mtx); 941 mutex_destroy(&tas->mtx);
928 kfree(tas); 942 kfree(tas);
@@ -970,14 +984,11 @@ static int tas_i2c_attach(struct i2c_adapter *adapter)
970 return -ENODEV; 984 return -ENODEV;
971} 985}
972 986
973static int tas_i2c_detach(struct i2c_client *client) 987static int tas_i2c_remove(struct i2c_client *client)
974{ 988{
975 struct tas *tas = container_of(client, struct tas, i2c); 989 struct tas *tas = i2c_get_clientdata(client);
976 int err;
977 u8 tmp = TAS_ACR_ANALOG_PDOWN; 990 u8 tmp = TAS_ACR_ANALOG_PDOWN;
978 991
979 if ((err = i2c_detach_client(client)))
980 return err;
981 aoa_codec_unregister(&tas->codec); 992 aoa_codec_unregister(&tas->codec);
982 of_node_put(tas->codec.node); 993 of_node_put(tas->codec.node);
983 994
@@ -989,13 +1000,20 @@ static int tas_i2c_detach(struct i2c_client *client)
989 return 0; 1000 return 0;
990} 1001}
991 1002
1003static const struct i2c_device_id tas_i2c_id[] = {
1004 { "aoa_codec_tas", 0 },
1005 { }
1006};
1007
992static struct i2c_driver tas_driver = { 1008static struct i2c_driver tas_driver = {
993 .driver = { 1009 .driver = {
994 .name = "aoa_codec_tas", 1010 .name = "aoa_codec_tas",
995 .owner = THIS_MODULE, 1011 .owner = THIS_MODULE,
996 }, 1012 },
997 .attach_adapter = tas_i2c_attach, 1013 .attach_adapter = tas_i2c_attach,
998 .detach_client = tas_i2c_detach, 1014 .probe = tas_i2c_probe,
1015 .remove = tas_i2c_remove,
1016 .id_table = tas_i2c_id,
999}; 1017};
1000 1018
1001static int __init tas_init(void) 1019static int __init tas_init(void)
diff --git a/sound/pci/atiixp.c b/sound/pci/atiixp.c
index 9ce8548c03e4..71515ddb4593 100644
--- a/sound/pci/atiixp.c
+++ b/sound/pci/atiixp.c
@@ -1393,6 +1393,12 @@ static struct ac97_quirk ac97_quirks[] __devinitdata = {
1393 .name = "HP nx6125", 1393 .name = "HP nx6125",
1394 .type = AC97_TUNE_MUTE_LED 1394 .type = AC97_TUNE_MUTE_LED
1395 }, 1395 },
1396 {
1397 .subvendor = 0x103c,
1398 .subdevice = 0x3091,
1399 .name = "unknown HP",
1400 .type = AC97_TUNE_MUTE_LED
1401 },
1396 { } /* terminator */ 1402 { } /* terminator */
1397}; 1403};
1398 1404
diff --git a/sound/pci/emu10k1/io.c b/sound/pci/emu10k1/io.c
index 4bfc31d1b281..c1a5aa15af8f 100644
--- a/sound/pci/emu10k1/io.c
+++ b/sound/pci/emu10k1/io.c
@@ -490,7 +490,7 @@ void snd_emu10k1_wait(struct snd_emu10k1 *emu, unsigned int wait)
490 if (newtime != curtime) 490 if (newtime != curtime)
491 break; 491 break;
492 } 492 }
493 if (count >= 16384) 493 if (count > 16384)
494 break; 494 break;
495 curtime = newtime; 495 curtime = newtime;
496 } 496 }
diff --git a/sound/pci/intel8x0.c b/sound/pci/intel8x0.c
index 5dced5b79387..8042d5398892 100644
--- a/sound/pci/intel8x0.c
+++ b/sound/pci/intel8x0.c
@@ -1854,6 +1854,12 @@ static struct ac97_quirk ac97_quirks[] __devinitdata = {
1854 }, 1854 },
1855 { 1855 {
1856 .subvendor = 0x1028, 1856 .subvendor = 0x1028,
1857 .subdevice = 0x016a,
1858 .name = "Dell Inspiron 8600", /* STAC9750/51 */
1859 .type = AC97_TUNE_HP_ONLY
1860 },
1861 {
1862 .subvendor = 0x1028,
1857 .subdevice = 0x0186, 1863 .subdevice = 0x0186,
1858 .name = "Dell Latitude D810", /* cf. Malone #41015 */ 1864 .name = "Dell Latitude D810", /* cf. Malone #41015 */
1859 .type = AC97_TUNE_HP_MUTE_LED 1865 .type = AC97_TUNE_HP_MUTE_LED
@@ -1896,12 +1902,6 @@ static struct ac97_quirk ac97_quirks[] __devinitdata = {
1896 }, 1902 },
1897 { 1903 {
1898 .subvendor = 0x103c, 1904 .subvendor = 0x103c,
1899 .subdevice = 0x0934,
1900 .name = "HP nx8220",
1901 .type = AC97_TUNE_MUTE_LED
1902 },
1903 {
1904 .subvendor = 0x103c,
1905 .subdevice = 0x129d, 1905 .subdevice = 0x129d,
1906 .name = "HP xw8000", 1906 .name = "HP xw8000",
1907 .type = AC97_TUNE_HP_ONLY 1907 .type = AC97_TUNE_HP_ONLY
diff --git a/sound/ppc/keywest.c b/sound/ppc/keywest.c
index 6ff99ed77516..a5afb2682e7f 100644
--- a/sound/ppc/keywest.c
+++ b/sound/ppc/keywest.c
@@ -33,26 +33,25 @@
33static struct pmac_keywest *keywest_ctx; 33static struct pmac_keywest *keywest_ctx;
34 34
35 35
36static int keywest_attach_adapter(struct i2c_adapter *adapter);
37static int keywest_detach_client(struct i2c_client *client);
38
39struct i2c_driver keywest_driver = {
40 .driver = {
41 .name = "PMac Keywest Audio",
42 },
43 .attach_adapter = &keywest_attach_adapter,
44 .detach_client = &keywest_detach_client,
45};
46
47
48#ifndef i2c_device_name 36#ifndef i2c_device_name
49#define i2c_device_name(x) ((x)->name) 37#define i2c_device_name(x) ((x)->name)
50#endif 38#endif
51 39
40static int keywest_probe(struct i2c_client *client,
41 const struct i2c_device_id *id)
42{
43 i2c_set_clientdata(client, keywest_ctx);
44 return 0;
45}
46
47/*
48 * This is kind of a hack, best would be to turn powermac to fixed i2c
49 * bus numbers and declare the sound device as part of platform
50 * initialization
51 */
52static int keywest_attach_adapter(struct i2c_adapter *adapter) 52static int keywest_attach_adapter(struct i2c_adapter *adapter)
53{ 53{
54 int err; 54 struct i2c_board_info info;
55 struct i2c_client *new_client;
56 55
57 if (! keywest_ctx) 56 if (! keywest_ctx)
58 return -EINVAL; 57 return -EINVAL;
@@ -60,46 +59,47 @@ static int keywest_attach_adapter(struct i2c_adapter *adapter)
60 if (strncmp(i2c_device_name(adapter), "mac-io", 6)) 59 if (strncmp(i2c_device_name(adapter), "mac-io", 6))
61 return 0; /* ignored */ 60 return 0; /* ignored */
62 61
63 new_client = kzalloc(sizeof(struct i2c_client), GFP_KERNEL); 62 memset(&info, 0, sizeof(struct i2c_board_info));
64 if (! new_client) 63 strlcpy(info.type, "keywest", I2C_NAME_SIZE);
65 return -ENOMEM; 64 info.addr = keywest_ctx->addr;
66 65 keywest_ctx->client = i2c_new_device(adapter, &info);
67 new_client->addr = keywest_ctx->addr;
68 i2c_set_clientdata(new_client, keywest_ctx);
69 new_client->adapter = adapter;
70 new_client->driver = &keywest_driver;
71 new_client->flags = 0;
72
73 strcpy(i2c_device_name(new_client), keywest_ctx->name);
74 keywest_ctx->client = new_client;
75 66
76 /* Tell the i2c layer a new client has arrived */ 67 /*
77 if (i2c_attach_client(new_client)) { 68 * Let i2c-core delete that device on driver removal.
78 snd_printk(KERN_ERR "tumbler: cannot attach i2c client\n"); 69 * This is safe because i2c-core holds the core_lock mutex for us.
79 err = -ENODEV; 70 */
80 goto __err; 71 list_add_tail(&keywest_ctx->client->detected,
81 } 72 &keywest_ctx->client->driver->clients);
82
83 return 0; 73 return 0;
84
85 __err:
86 kfree(new_client);
87 keywest_ctx->client = NULL;
88 return err;
89} 74}
90 75
91static int keywest_detach_client(struct i2c_client *client) 76static int keywest_remove(struct i2c_client *client)
92{ 77{
78 i2c_set_clientdata(client, NULL);
93 if (! keywest_ctx) 79 if (! keywest_ctx)
94 return 0; 80 return 0;
95 if (client == keywest_ctx->client) 81 if (client == keywest_ctx->client)
96 keywest_ctx->client = NULL; 82 keywest_ctx->client = NULL;
97 83
98 i2c_detach_client(client);
99 kfree(client);
100 return 0; 84 return 0;
101} 85}
102 86
87
88static const struct i2c_device_id keywest_i2c_id[] = {
89 { "keywest", 0 },
90 { }
91};
92
93struct i2c_driver keywest_driver = {
94 .driver = {
95 .name = "PMac Keywest Audio",
96 },
97 .attach_adapter = keywest_attach_adapter,
98 .probe = keywest_probe,
99 .remove = keywest_remove,
100 .id_table = keywest_i2c_id,
101};
102
103/* exported */ 103/* exported */
104void snd_pmac_keywest_cleanup(struct pmac_keywest *i2c) 104void snd_pmac_keywest_cleanup(struct pmac_keywest *i2c)
105{ 105{
diff --git a/sound/soc/codecs/wm9705.c b/sound/soc/codecs/wm9705.c
index 6e23a81dba78..c2d1a7a18fa3 100644
--- a/sound/soc/codecs/wm9705.c
+++ b/sound/soc/codecs/wm9705.c
@@ -318,7 +318,7 @@ static int wm9705_reset(struct snd_soc_codec *codec)
318} 318}
319 319
320#ifdef CONFIG_PM 320#ifdef CONFIG_PM
321static int wm9705_soc_suspend(struct platform_device *pdev) 321static int wm9705_soc_suspend(struct platform_device *pdev, pm_message_t msg)
322{ 322{
323 struct snd_soc_device *socdev = platform_get_drvdata(pdev); 323 struct snd_soc_device *socdev = platform_get_drvdata(pdev);
324 struct snd_soc_codec *codec = socdev->card->codec; 324 struct snd_soc_codec *codec = socdev->card->codec;
diff --git a/sound/soc/omap/n810.c b/sound/soc/omap/n810.c
index a6d1178ce128..91ef17992de5 100644
--- a/sound/soc/omap/n810.c
+++ b/sound/soc/omap/n810.c
@@ -3,7 +3,7 @@
3 * 3 *
4 * Copyright (C) 2008 Nokia Corporation 4 * Copyright (C) 2008 Nokia Corporation
5 * 5 *
6 * Contact: Jarkko Nikula <jarkko.nikula@nokia.com> 6 * Contact: Jarkko Nikula <jhnikula@gmail.com>
7 * 7 *
8 * This program is free software; you can redistribute it and/or 8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License 9 * modify it under the terms of the GNU General Public License
@@ -417,6 +417,6 @@ static void __exit n810_soc_exit(void)
417module_init(n810_soc_init); 417module_init(n810_soc_init);
418module_exit(n810_soc_exit); 418module_exit(n810_soc_exit);
419 419
420MODULE_AUTHOR("Jarkko Nikula <jarkko.nikula@nokia.com>"); 420MODULE_AUTHOR("Jarkko Nikula <jhnikula@gmail.com>");
421MODULE_DESCRIPTION("ALSA SoC Nokia N810"); 421MODULE_DESCRIPTION("ALSA SoC Nokia N810");
422MODULE_LICENSE("GPL"); 422MODULE_LICENSE("GPL");
diff --git a/sound/soc/omap/omap-mcbsp.c b/sound/soc/omap/omap-mcbsp.c
index 9c09b94f0cf8..912614283848 100644
--- a/sound/soc/omap/omap-mcbsp.c
+++ b/sound/soc/omap/omap-mcbsp.c
@@ -3,7 +3,8 @@
3 * 3 *
4 * Copyright (C) 2008 Nokia Corporation 4 * Copyright (C) 2008 Nokia Corporation
5 * 5 *
6 * Contact: Jarkko Nikula <jarkko.nikula@nokia.com> 6 * Contact: Jarkko Nikula <jhnikula@gmail.com>
7 * Peter Ujfalusi <peter.ujfalusi@nokia.com>
7 * 8 *
8 * This program is free software; you can redistribute it and/or 9 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License 10 * modify it under the terms of the GNU General Public License
@@ -283,7 +284,7 @@ static int omap_mcbsp_dai_hw_params(struct snd_pcm_substream *substream,
283 break; 284 break;
284 case SND_SOC_DAIFMT_DSP_B: 285 case SND_SOC_DAIFMT_DSP_B:
285 regs->srgr2 |= FPER(wlen * channels - 1); 286 regs->srgr2 |= FPER(wlen * channels - 1);
286 regs->srgr1 |= FWID(wlen * channels - 2); 287 regs->srgr1 |= FWID(0);
287 break; 288 break;
288 } 289 }
289 290
@@ -302,6 +303,7 @@ static int omap_mcbsp_dai_set_dai_fmt(struct snd_soc_dai *cpu_dai,
302{ 303{
303 struct omap_mcbsp_data *mcbsp_data = to_mcbsp(cpu_dai->private_data); 304 struct omap_mcbsp_data *mcbsp_data = to_mcbsp(cpu_dai->private_data);
304 struct omap_mcbsp_reg_cfg *regs = &mcbsp_data->regs; 305 struct omap_mcbsp_reg_cfg *regs = &mcbsp_data->regs;
306 unsigned int temp_fmt = fmt;
305 307
306 if (mcbsp_data->configured) 308 if (mcbsp_data->configured)
307 return 0; 309 return 0;
@@ -328,6 +330,8 @@ static int omap_mcbsp_dai_set_dai_fmt(struct snd_soc_dai *cpu_dai,
328 /* 0-bit data delay */ 330 /* 0-bit data delay */
329 regs->rcr2 |= RDATDLY(0); 331 regs->rcr2 |= RDATDLY(0);
330 regs->xcr2 |= XDATDLY(0); 332 regs->xcr2 |= XDATDLY(0);
333 /* Invert FS polarity configuration */
334 temp_fmt ^= SND_SOC_DAIFMT_NB_IF;
331 break; 335 break;
332 default: 336 default:
333 /* Unsupported data format */ 337 /* Unsupported data format */
@@ -351,7 +355,7 @@ static int omap_mcbsp_dai_set_dai_fmt(struct snd_soc_dai *cpu_dai,
351 } 355 }
352 356
353 /* Set bit clock (CLKX/CLKR) and FS polarities */ 357 /* Set bit clock (CLKX/CLKR) and FS polarities */
354 switch (fmt & SND_SOC_DAIFMT_INV_MASK) { 358 switch (temp_fmt & SND_SOC_DAIFMT_INV_MASK) {
355 case SND_SOC_DAIFMT_NB_NF: 359 case SND_SOC_DAIFMT_NB_NF:
356 /* 360 /*
357 * Normal BCLK + FS. 361 * Normal BCLK + FS.
@@ -529,6 +533,6 @@ static void __exit snd_omap_mcbsp_exit(void)
529} 533}
530module_exit(snd_omap_mcbsp_exit); 534module_exit(snd_omap_mcbsp_exit);
531 535
532MODULE_AUTHOR("Jarkko Nikula <jarkko.nikula@nokia.com>"); 536MODULE_AUTHOR("Jarkko Nikula <jhnikula@gmail.com>");
533MODULE_DESCRIPTION("OMAP I2S SoC Interface"); 537MODULE_DESCRIPTION("OMAP I2S SoC Interface");
534MODULE_LICENSE("GPL"); 538MODULE_LICENSE("GPL");
diff --git a/sound/soc/omap/omap-mcbsp.h b/sound/soc/omap/omap-mcbsp.h
index df7ad13ba73d..c8147aace813 100644
--- a/sound/soc/omap/omap-mcbsp.h
+++ b/sound/soc/omap/omap-mcbsp.h
@@ -3,7 +3,8 @@
3 * 3 *
4 * Copyright (C) 2008 Nokia Corporation 4 * Copyright (C) 2008 Nokia Corporation
5 * 5 *
6 * Contact: Jarkko Nikula <jarkko.nikula@nokia.com> 6 * Contact: Jarkko Nikula <jhnikula@gmail.com>
7 * Peter Ujfalusi <peter.ujfalusi@nokia.com>
7 * 8 *
8 * This program is free software; you can redistribute it and/or 9 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License 10 * modify it under the terms of the GNU General Public License
diff --git a/sound/soc/omap/omap-pcm.c b/sound/soc/omap/omap-pcm.c
index 1bdbb0427183..07cf7f46b584 100644
--- a/sound/soc/omap/omap-pcm.c
+++ b/sound/soc/omap/omap-pcm.c
@@ -3,7 +3,8 @@
3 * 3 *
4 * Copyright (C) 2008 Nokia Corporation 4 * Copyright (C) 2008 Nokia Corporation
5 * 5 *
6 * Contact: Jarkko Nikula <jarkko.nikula@nokia.com> 6 * Contact: Jarkko Nikula <jhnikula@gmail.com>
7 * Peter Ujfalusi <peter.ujfalusi@nokia.com>
7 * 8 *
8 * This program is free software; you can redistribute it and/or 9 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License 10 * modify it under the terms of the GNU General Public License
@@ -367,6 +368,6 @@ static void __exit omap_soc_platform_exit(void)
367} 368}
368module_exit(omap_soc_platform_exit); 369module_exit(omap_soc_platform_exit);
369 370
370MODULE_AUTHOR("Jarkko Nikula <jarkko.nikula@nokia.com>"); 371MODULE_AUTHOR("Jarkko Nikula <jhnikula@gmail.com>");
371MODULE_DESCRIPTION("OMAP PCM DMA module"); 372MODULE_DESCRIPTION("OMAP PCM DMA module");
372MODULE_LICENSE("GPL"); 373MODULE_LICENSE("GPL");
diff --git a/sound/soc/omap/omap-pcm.h b/sound/soc/omap/omap-pcm.h
index e4369bdfd77d..8d9d26916b05 100644
--- a/sound/soc/omap/omap-pcm.h
+++ b/sound/soc/omap/omap-pcm.h
@@ -3,7 +3,8 @@
3 * 3 *
4 * Copyright (C) 2008 Nokia Corporation 4 * Copyright (C) 2008 Nokia Corporation
5 * 5 *
6 * Contact: Jarkko Nikula <jarkko.nikula@nokia.com> 6 * Contact: Jarkko Nikula <jhnikula@gmail.com>
7 * Peter Ujfalusi <peter.ujfalusi@nokia.com>
7 * 8 *
8 * This program is free software; you can redistribute it and/or 9 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License 10 * modify it under the terms of the GNU General Public License
diff --git a/sound/soc/omap/osk5912.c b/sound/soc/omap/osk5912.c
index a952a4eb3361..a4e149b7f0eb 100644
--- a/sound/soc/omap/osk5912.c
+++ b/sound/soc/omap/osk5912.c
@@ -62,7 +62,7 @@ static int osk_hw_params(struct snd_pcm_substream *substream,
62 /* Set codec DAI configuration */ 62 /* Set codec DAI configuration */
63 err = snd_soc_dai_set_fmt(codec_dai, 63 err = snd_soc_dai_set_fmt(codec_dai,
64 SND_SOC_DAIFMT_DSP_B | 64 SND_SOC_DAIFMT_DSP_B |
65 SND_SOC_DAIFMT_NB_IF | 65 SND_SOC_DAIFMT_NB_NF |
66 SND_SOC_DAIFMT_CBM_CFM); 66 SND_SOC_DAIFMT_CBM_CFM);
67 if (err < 0) { 67 if (err < 0) {
68 printk(KERN_ERR "can't set codec DAI configuration\n"); 68 printk(KERN_ERR "can't set codec DAI configuration\n");
@@ -72,7 +72,7 @@ static int osk_hw_params(struct snd_pcm_substream *substream,
72 /* Set cpu DAI configuration */ 72 /* Set cpu DAI configuration */
73 err = snd_soc_dai_set_fmt(cpu_dai, 73 err = snd_soc_dai_set_fmt(cpu_dai,
74 SND_SOC_DAIFMT_DSP_B | 74 SND_SOC_DAIFMT_DSP_B |
75 SND_SOC_DAIFMT_NB_IF | 75 SND_SOC_DAIFMT_NB_NF |
76 SND_SOC_DAIFMT_CBM_CFM); 76 SND_SOC_DAIFMT_CBM_CFM);
77 if (err < 0) { 77 if (err < 0) {
78 printk(KERN_ERR "can't set cpu DAI configuration\n"); 78 printk(KERN_ERR "can't set cpu DAI configuration\n");
diff --git a/sound/soc/pxa/pxa-ssp.c b/sound/soc/pxa/pxa-ssp.c
index 308a657928d2..286be31545df 100644
--- a/sound/soc/pxa/pxa-ssp.c
+++ b/sound/soc/pxa/pxa-ssp.c
@@ -280,12 +280,33 @@ static int pxa_ssp_resume(struct snd_soc_dai *cpu_dai)
280 * ssp_set_clkdiv - set SSP clock divider 280 * ssp_set_clkdiv - set SSP clock divider
281 * @div: serial clock rate divider 281 * @div: serial clock rate divider
282 */ 282 */
283static void ssp_set_scr(struct ssp_dev *dev, u32 div) 283static void ssp_set_scr(struct ssp_device *ssp, u32 div)
284{ 284{
285 struct ssp_device *ssp = dev->ssp; 285 u32 sscr0 = ssp_read_reg(ssp, SSCR0);
286 u32 sscr0 = ssp_read_reg(dev->ssp, SSCR0) & ~SSCR0_SCR; 286
287 if (cpu_is_pxa25x() && ssp->type == PXA25x_SSP) {
288 sscr0 &= ~0x0000ff00;
289 sscr0 |= ((div - 2)/2) << 8; /* 2..512 */
290 } else {
291 sscr0 &= ~0x000fff00;
292 sscr0 |= (div - 1) << 8; /* 1..4096 */
293 }
294 ssp_write_reg(ssp, SSCR0, sscr0);
295}
296
297/**
298 * ssp_get_clkdiv - get SSP clock divider
299 */
300static u32 ssp_get_scr(struct ssp_device *ssp)
301{
302 u32 sscr0 = ssp_read_reg(ssp, SSCR0);
303 u32 div;
287 304
288 ssp_write_reg(ssp, SSCR0, (sscr0 | SSCR0_SerClkDiv(div))); 305 if (cpu_is_pxa25x() && ssp->type == PXA25x_SSP)
306 div = ((sscr0 >> 8) & 0xff) * 2 + 2;
307 else
308 div = ((sscr0 >> 8) & 0xfff) + 1;
309 return div;
289} 310}
290 311
291/* 312/*
@@ -326,7 +347,7 @@ static int pxa_ssp_set_dai_sysclk(struct snd_soc_dai *cpu_dai,
326 break; 347 break;
327 case PXA_SSP_CLK_AUDIO: 348 case PXA_SSP_CLK_AUDIO:
328 priv->sysclk = 0; 349 priv->sysclk = 0;
329 ssp_set_scr(&priv->dev, 1); 350 ssp_set_scr(ssp, 1);
330 sscr0 |= SSCR0_ACS; 351 sscr0 |= SSCR0_ACS;
331 break; 352 break;
332 default: 353 default:
@@ -387,7 +408,7 @@ static int pxa_ssp_set_dai_clkdiv(struct snd_soc_dai *cpu_dai,
387 ssp_write_reg(ssp, SSACD, val); 408 ssp_write_reg(ssp, SSACD, val);
388 break; 409 break;
389 case PXA_SSP_DIV_SCR: 410 case PXA_SSP_DIV_SCR:
390 ssp_set_scr(&priv->dev, div); 411 ssp_set_scr(ssp, div);
391 break; 412 break;
392 default: 413 default:
393 return -ENODEV; 414 return -ENODEV;
@@ -674,8 +695,7 @@ static int pxa_ssp_hw_params(struct snd_pcm_substream *substream,
674 case SND_SOC_DAIFMT_I2S: 695 case SND_SOC_DAIFMT_I2S:
675 sspsp = ssp_read_reg(ssp, SSPSP); 696 sspsp = ssp_read_reg(ssp, SSPSP);
676 697
677 if (((sscr0 & SSCR0_SCR) == SSCR0_SerClkDiv(4)) && 698 if ((ssp_get_scr(ssp) == 4) && (width == 16)) {
678 (width == 16)) {
679 /* This is a special case where the bitclk is 64fs 699 /* This is a special case where the bitclk is 64fs
680 * and we're not dealing with 2*32 bits of audio 700 * and we're not dealing with 2*32 bits of audio
681 * samples. 701 * samples.
@@ -806,6 +826,7 @@ static int pxa_ssp_probe(struct platform_device *pdev,
806 goto err_priv; 826 goto err_priv;
807 } 827 }
808 828
829 priv->dai_fmt = (unsigned int) -1;
809 dai->private_data = priv; 830 dai->private_data = priv;
810 831
811 return 0; 832 return 0;
diff --git a/sound/soc/s3c24xx/jive_wm8750.c b/sound/soc/s3c24xx/jive_wm8750.c
index 32063790d95b..93e6c87b7399 100644
--- a/sound/soc/s3c24xx/jive_wm8750.c
+++ b/sound/soc/s3c24xx/jive_wm8750.c
@@ -69,8 +69,8 @@ static int jive_hw_params(struct snd_pcm_substream *substream,
69 break; 69 break;
70 } 70 }
71 71
72 s3c_i2sv2_calc_rate(&div, NULL, params_rate(params), 72 s3c_i2sv2_iis_calc_rate(&div, NULL, params_rate(params),
73 s3c2412_get_iisclk()); 73 s3c2412_get_iisclk());
74 74
75 /* set codec DAI configuration */ 75 /* set codec DAI configuration */
76 ret = snd_soc_dai_set_fmt(codec_dai, SND_SOC_DAIFMT_I2S | 76 ret = snd_soc_dai_set_fmt(codec_dai, SND_SOC_DAIFMT_I2S |
@@ -145,8 +145,9 @@ static struct snd_soc_dai_link jive_dai = {
145}; 145};
146 146
147/* jive audio machine driver */ 147/* jive audio machine driver */
148static struct snd_soc_machine snd_soc_machine_jive = { 148static struct snd_soc_card snd_soc_machine_jive = {
149 .name = "Jive", 149 .name = "Jive",
150 .platform = &s3c24xx_soc_platform,
150 .dai_link = &jive_dai, 151 .dai_link = &jive_dai,
151 .num_links = 1, 152 .num_links = 1,
152}; 153};
@@ -157,9 +158,8 @@ static struct wm8750_setup_data jive_wm8750_setup = {
157 158
158/* jive audio subsystem */ 159/* jive audio subsystem */
159static struct snd_soc_device jive_snd_devdata = { 160static struct snd_soc_device jive_snd_devdata = {
160 .machine = &snd_soc_machine_jive, 161 .card = &snd_soc_machine_jive,
161 .platform = &s3c24xx_soc_platform, 162 .codec_dev = &soc_codec_dev_wm8750,
162 .codec_dev = &soc_codec_dev_wm8750_spi,
163 .codec_data = &jive_wm8750_setup, 163 .codec_data = &jive_wm8750_setup,
164}; 164};
165 165
diff --git a/sound/soc/s3c24xx/s3c-i2s-v2.c b/sound/soc/s3c24xx/s3c-i2s-v2.c
index 295a4c910262..689ffcd17e1f 100644
--- a/sound/soc/s3c24xx/s3c-i2s-v2.c
+++ b/sound/soc/s3c24xx/s3c-i2s-v2.c
@@ -473,9 +473,9 @@ static int s3c2412_i2s_set_clkdiv(struct snd_soc_dai *cpu_dai,
473/* default table of all avaialable root fs divisors */ 473/* default table of all avaialable root fs divisors */
474static unsigned int iis_fs_tab[] = { 256, 512, 384, 768 }; 474static unsigned int iis_fs_tab[] = { 256, 512, 384, 768 };
475 475
476int s3c2412_iis_calc_rate(struct s3c_i2sv2_rate_calc *info, 476int s3c_i2sv2_iis_calc_rate(struct s3c_i2sv2_rate_calc *info,
477 unsigned int *fstab, 477 unsigned int *fstab,
478 unsigned int rate, struct clk *clk) 478 unsigned int rate, struct clk *clk)
479{ 479{
480 unsigned long clkrate = clk_get_rate(clk); 480 unsigned long clkrate = clk_get_rate(clk);
481 unsigned int div; 481 unsigned int div;
@@ -531,7 +531,7 @@ int s3c2412_iis_calc_rate(struct s3c_i2sv2_rate_calc *info,
531 531
532 return 0; 532 return 0;
533} 533}
534EXPORT_SYMBOL_GPL(s3c2412_iis_calc_rate); 534EXPORT_SYMBOL_GPL(s3c_i2sv2_iis_calc_rate);
535 535
536int s3c_i2sv2_probe(struct platform_device *pdev, 536int s3c_i2sv2_probe(struct platform_device *pdev,
537 struct snd_soc_dai *dai, 537 struct snd_soc_dai *dai,
@@ -624,10 +624,12 @@ static int s3c2412_i2s_resume(struct snd_soc_dai *dai)
624 624
625int s3c_i2sv2_register_dai(struct snd_soc_dai *dai) 625int s3c_i2sv2_register_dai(struct snd_soc_dai *dai)
626{ 626{
627 dai->ops.trigger = s3c2412_i2s_trigger; 627 struct snd_soc_dai_ops *ops = dai->ops;
628 dai->ops.hw_params = s3c2412_i2s_hw_params; 628
629 dai->ops.set_fmt = s3c2412_i2s_set_fmt; 629 ops->trigger = s3c2412_i2s_trigger;
630 dai->ops.set_clkdiv = s3c2412_i2s_set_clkdiv; 630 ops->hw_params = s3c2412_i2s_hw_params;
631 ops->set_fmt = s3c2412_i2s_set_fmt;
632 ops->set_clkdiv = s3c2412_i2s_set_clkdiv;
631 633
632 dai->suspend = s3c2412_i2s_suspend; 634 dai->suspend = s3c2412_i2s_suspend;
633 dai->resume = s3c2412_i2s_resume; 635 dai->resume = s3c2412_i2s_resume;
diff --git a/sound/soc/s3c24xx/s3c2412-i2s.c b/sound/soc/s3c24xx/s3c2412-i2s.c
index 1ca3cdaa8213..b7e0b3f0bfc8 100644
--- a/sound/soc/s3c24xx/s3c2412-i2s.c
+++ b/sound/soc/s3c24xx/s3c2412-i2s.c
@@ -33,8 +33,8 @@
33 33
34#include <plat/regs-s3c2412-iis.h> 34#include <plat/regs-s3c2412-iis.h>
35 35
36#include <plat/regs-gpio.h>
37#include <plat/audio.h> 36#include <plat/audio.h>
37#include <mach/regs-gpio.h>
38#include <mach/dma.h> 38#include <mach/dma.h>
39 39
40#include "s3c24xx-pcm.h" 40#include "s3c24xx-pcm.h"
diff --git a/sound/usb/usx2y/us122l.c b/sound/usb/usx2y/us122l.c
index 012ff1f6f8af..a5aae9d67f31 100644
--- a/sound/usb/usx2y/us122l.c
+++ b/sound/usb/usx2y/us122l.c
@@ -474,6 +474,14 @@ static bool us122l_create_card(struct snd_card *card)
474 return true; 474 return true;
475} 475}
476 476
477static void snd_us122l_free(struct snd_card *card)
478{
479 struct us122l *us122l = US122L(card);
480 int index = us122l->chip.index;
481 if (index >= 0 && index < SNDRV_CARDS)
482 snd_us122l_card_used[index] = 0;
483}
484
477static int usx2y_create_card(struct usb_device *device, struct snd_card **cardp) 485static int usx2y_create_card(struct usb_device *device, struct snd_card **cardp)
478{ 486{
479 int dev; 487 int dev;
@@ -490,7 +498,7 @@ static int usx2y_create_card(struct usb_device *device, struct snd_card **cardp)
490 if (err < 0) 498 if (err < 0)
491 return err; 499 return err;
492 snd_us122l_card_used[US122L(card)->chip.index = dev] = 1; 500 snd_us122l_card_used[US122L(card)->chip.index = dev] = 1;
493 501 card->private_free = snd_us122l_free;
494 US122L(card)->chip.dev = device; 502 US122L(card)->chip.dev = device;
495 US122L(card)->chip.card = card; 503 US122L(card)->chip.card = card;
496 mutex_init(&US122L(card)->mutex); 504 mutex_init(&US122L(card)->mutex);
@@ -584,7 +592,7 @@ static void snd_us122l_disconnect(struct usb_interface *intf)
584 } 592 }
585 593
586 usb_put_intf(intf); 594 usb_put_intf(intf);
587 usb_put_dev(US122L(card)->chip.dev); 595 usb_put_dev(us122l->chip.dev);
588 596
589 while (atomic_read(&us122l->mmap_count)) 597 while (atomic_read(&us122l->mmap_count))
590 msleep(500); 598 msleep(500);
diff --git a/sound/usb/usx2y/usb_stream.c b/sound/usb/usx2y/usb_stream.c
index 24393dafcb6e..12ae0340adc0 100644
--- a/sound/usb/usx2y/usb_stream.c
+++ b/sound/usb/usx2y/usb_stream.c
@@ -33,32 +33,26 @@ static unsigned usb_stream_next_packet_size(struct usb_stream_kernel *sk)
33static void playback_prep_freqn(struct usb_stream_kernel *sk, struct urb *urb) 33static void playback_prep_freqn(struct usb_stream_kernel *sk, struct urb *urb)
34{ 34{
35 struct usb_stream *s = sk->s; 35 struct usb_stream *s = sk->s;
36 unsigned l = 0; 36 int pack, lb = 0;
37 int pack; 37
38 38 for (pack = 0; pack < sk->n_o_ps; pack++) {
39 urb->iso_frame_desc[0].offset = 0; 39 int l = usb_stream_next_packet_size(sk);
40 urb->iso_frame_desc[0].length = usb_stream_next_packet_size(sk); 40 if (s->idle_outsize + lb + l > s->period_size)
41 sk->out_phase = sk->out_phase_peeked;
42 urb->transfer_buffer_length = urb->iso_frame_desc[0].length;
43
44 for (pack = 1; pack < sk->n_o_ps; pack++) {
45 l = usb_stream_next_packet_size(sk);
46 if (s->idle_outsize + urb->transfer_buffer_length + l >
47 s->period_size)
48 goto check; 41 goto check;
49 42
50 sk->out_phase = sk->out_phase_peeked; 43 sk->out_phase = sk->out_phase_peeked;
51 urb->iso_frame_desc[pack].offset = urb->transfer_buffer_length; 44 urb->iso_frame_desc[pack].offset = lb;
52 urb->iso_frame_desc[pack].length = l; 45 urb->iso_frame_desc[pack].length = l;
53 urb->transfer_buffer_length += l; 46 lb += l;
54 } 47 }
55 snd_printdd(KERN_DEBUG "%i\n", urb->transfer_buffer_length); 48 snd_printdd(KERN_DEBUG "%i\n", lb);
56 49
57check: 50check:
58 urb->number_of_packets = pack; 51 urb->number_of_packets = pack;
59 s->idle_outsize += urb->transfer_buffer_length - s->period_size; 52 urb->transfer_buffer_length = lb;
53 s->idle_outsize += lb - s->period_size;
60 snd_printdd(KERN_DEBUG "idle=%i ul=%i ps=%i\n", s->idle_outsize, 54 snd_printdd(KERN_DEBUG "idle=%i ul=%i ps=%i\n", s->idle_outsize,
61 urb->transfer_buffer_length, s->period_size); 55 lb, s->period_size);
62} 56}
63 57
64static void init_pipe_urbs(struct usb_stream_kernel *sk, unsigned use_packsize, 58static void init_pipe_urbs(struct usb_stream_kernel *sk, unsigned use_packsize,
@@ -282,21 +276,20 @@ static int usb_stream_prepare_playback(struct usb_stream_kernel *sk,
282 struct usb_stream *s = sk->s; 276 struct usb_stream *s = sk->s;
283 struct urb *io; 277 struct urb *io;
284 struct usb_iso_packet_descriptor *id, *od; 278 struct usb_iso_packet_descriptor *id, *od;
285 int p, l = 0; 279 int p = 0, lb = 0, l = 0;
286 280
287 io = sk->idle_outurb; 281 io = sk->idle_outurb;
288 od = io->iso_frame_desc; 282 od = io->iso_frame_desc;
289 io->transfer_buffer_length = 0;
290 283
291 for (p = 0; s->sync_packet < 0; ++p, ++s->sync_packet) { 284 for (; s->sync_packet < 0; ++p, ++s->sync_packet) {
292 struct urb *ii = sk->completed_inurb; 285 struct urb *ii = sk->completed_inurb;
293 id = ii->iso_frame_desc + 286 id = ii->iso_frame_desc +
294 ii->number_of_packets + s->sync_packet; 287 ii->number_of_packets + s->sync_packet;
295 l = id->actual_length; 288 l = id->actual_length;
296 289
297 od[p].length = l; 290 od[p].length = l;
298 od[p].offset = io->transfer_buffer_length; 291 od[p].offset = lb;
299 io->transfer_buffer_length += l; 292 lb += l;
300 } 293 }
301 294
302 for (; 295 for (;
@@ -304,38 +297,38 @@ static int usb_stream_prepare_playback(struct usb_stream_kernel *sk,
304 ++p, ++s->sync_packet) { 297 ++p, ++s->sync_packet) {
305 l = inurb->iso_frame_desc[s->sync_packet].actual_length; 298 l = inurb->iso_frame_desc[s->sync_packet].actual_length;
306 299
307 if (s->idle_outsize + io->transfer_buffer_length + l > 300 if (s->idle_outsize + lb + l > s->period_size)
308 s->period_size)
309 goto check_ok; 301 goto check_ok;
310 302
311 od[p].length = l; 303 od[p].length = l;
312 od[p].offset = io->transfer_buffer_length; 304 od[p].offset = lb;
313 io->transfer_buffer_length += l; 305 lb += l;
314 } 306 }
315 307
316check_ok: 308check_ok:
317 s->sync_packet -= inurb->number_of_packets; 309 s->sync_packet -= inurb->number_of_packets;
318 if (s->sync_packet < -2 || s->sync_packet > 0) { 310 if (unlikely(s->sync_packet < -2 || s->sync_packet > 0)) {
319 snd_printk(KERN_WARNING "invalid sync_packet = %i;" 311 snd_printk(KERN_WARNING "invalid sync_packet = %i;"
320 " p=%i nop=%i %i %x %x %x > %x\n", 312 " p=%i nop=%i %i %x %x %x > %x\n",
321 s->sync_packet, p, inurb->number_of_packets, 313 s->sync_packet, p, inurb->number_of_packets,
322 s->idle_outsize + io->transfer_buffer_length + l, 314 s->idle_outsize + lb + l,
323 s->idle_outsize, io->transfer_buffer_length, l, 315 s->idle_outsize, lb, l,
324 s->period_size); 316 s->period_size);
325 return -1; 317 return -1;
326 } 318 }
327 if (io->transfer_buffer_length % s->cfg.frame_size) { 319 if (unlikely(lb % s->cfg.frame_size)) {
328 snd_printk(KERN_WARNING"invalid outsize = %i\n", 320 snd_printk(KERN_WARNING"invalid outsize = %i\n",
329 io->transfer_buffer_length); 321 lb);
330 return -1; 322 return -1;
331 } 323 }
332 s->idle_outsize += io->transfer_buffer_length - s->period_size; 324 s->idle_outsize += lb - s->period_size;
333 io->number_of_packets = p; 325 io->number_of_packets = p;
334 if (s->idle_outsize > 0) { 326 io->transfer_buffer_length = lb;
335 snd_printk(KERN_WARNING "idle=%i\n", s->idle_outsize); 327 if (s->idle_outsize <= 0)
336 return -1; 328 return 0;
337 } 329
338 return 0; 330 snd_printk(KERN_WARNING "idle=%i\n", s->idle_outsize);
331 return -1;
339} 332}
340 333
341static void prepare_inurb(int number_of_packets, struct urb *iu) 334static void prepare_inurb(int number_of_packets, struct urb *iu)