Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

Merge remote-tracking branches 'asoc/topic/txx9', 'asoc/topic/uda134x', 'asoc/topic/ux500' and 'asoc/topic/width' into asoc-next

+96 -141
+1 -1
sound/soc/codecs/max98925.c
··· 430 430 struct snd_soc_codec *codec = dai->codec; 431 431 struct max98925_priv *max98925 = snd_soc_codec_get_drvdata(codec); 432 432 433 - switch (snd_pcm_format_width(params_format(params))) { 433 + switch (params_width(params)) { 434 434 case 16: 435 435 regmap_update_bits(max98925->regmap, 436 436 MAX98925_FORMAT,
+2 -2
sound/soc/codecs/pcm512x.c
··· 1117 1117 params_rate(params), 1118 1118 params_channels(params)); 1119 1119 1120 - switch (snd_pcm_format_width(params_format(params))) { 1120 + switch (params_width(params)) { 1121 1121 case 16: 1122 1122 alen = PCM512x_ALEN_16; 1123 1123 break; ··· 1132 1132 break; 1133 1133 default: 1134 1134 dev_err(codec->dev, "Bad frame size: %d\n", 1135 - snd_pcm_format_width(params_format(params))); 1135 + params_width(params)); 1136 1136 return -EINVAL; 1137 1137 } 1138 1138
+76 -104
sound/soc/codecs/uda134x.c
··· 37 37 38 38 struct snd_pcm_substream *master_substream; 39 39 struct snd_pcm_substream *slave_substream; 40 + 41 + struct regmap *regmap; 42 + struct uda134x_platform_data *pd; 40 43 }; 41 44 42 - /* In-data addresses are hard-coded into the reg-cache values */ 43 - static const char uda134x_reg[UDA134X_REGS_NUM] = { 44 - /* Extended address registers */ 45 - 0x04, 0x04, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 46 - /* Status, data regs */ 47 - 0x00, 0x83, 0x00, 0x40, 0x80, 0xC0, 0x00, 45 + static const struct reg_default uda134x_reg_defaults[] = { 46 + { UDA134X_EA000, 0x04 }, 47 + { UDA134X_EA001, 0x04 }, 48 + { UDA134X_EA010, 0x04 }, 49 + { UDA134X_EA011, 0x00 }, 50 + { UDA134X_EA100, 0x00 }, 51 + { UDA134X_EA101, 0x00 }, 52 + { UDA134X_EA110, 0x00 }, 53 + { UDA134X_EA111, 0x00 }, 54 + { UDA134X_STATUS0, 0x00 }, 55 + { UDA134X_STATUS1, 0x03 }, 56 + { UDA134X_DATA000, 0x00 }, 57 + { UDA134X_DATA001, 0x00 }, 58 + { UDA134X_DATA010, 0x00 }, 59 + { UDA134X_DATA011, 0x00 }, 60 + { UDA134X_DATA1, 0x00 }, 48 61 }; 49 - 50 - /* 51 - * The codec has no support for reading its registers except for peak level... 52 - */ 53 - static inline unsigned int uda134x_read_reg_cache(struct snd_soc_codec *codec, 54 - unsigned int reg) 55 - { 56 - u8 *cache = codec->reg_cache; 57 - 58 - if (reg >= UDA134X_REGS_NUM) 59 - return -1; 60 - return cache[reg]; 61 - } 62 - 63 - /* 64 - * Write the register cache 65 - */ 66 - static inline void uda134x_write_reg_cache(struct snd_soc_codec *codec, 67 - u8 reg, unsigned int value) 68 - { 69 - u8 *cache = codec->reg_cache; 70 - 71 - if (reg >= UDA134X_REGS_NUM) 72 - return; 73 - cache[reg] = value; 74 - } 75 62 76 63 /* 77 64 * Write to the uda134x registers 78 65 * 79 66 */ 80 - static int uda134x_write(struct snd_soc_codec *codec, unsigned int reg, 67 + static int uda134x_regmap_write(void *context, unsigned int reg, 81 68 unsigned int value) 82 69 { 70 + struct uda134x_platform_data *pd = context; 83 71 int ret; 84 72 u8 addr; 85 73 u8 data = value; 86 - struct uda134x_platform_data *pd = codec->control_data; 87 - 88 - pr_debug("%s reg: %02X, value:%02X\n", __func__, reg, value); 89 - 90 - if (reg >= UDA134X_REGS_NUM) { 91 - printk(KERN_ERR "%s unknown register: reg: %u", 92 - __func__, reg); 93 - return -EINVAL; 94 - } 95 - 96 - uda134x_write_reg_cache(codec, reg, value); 97 74 98 75 switch (reg) { 99 76 case UDA134X_STATUS0: 100 77 case UDA134X_STATUS1: 101 78 addr = UDA134X_STATUS_ADDR; 79 + data |= (reg - UDA134X_STATUS0) << 7; 102 80 break; 103 81 case UDA134X_DATA000: 104 82 case UDA134X_DATA001: 105 83 case UDA134X_DATA010: 106 84 case UDA134X_DATA011: 107 85 addr = UDA134X_DATA0_ADDR; 86 + data |= (reg - UDA134X_DATA000) << 6; 108 87 break; 109 88 case UDA134X_DATA1: 110 89 addr = UDA134X_DATA1_ADDR; ··· 112 133 113 134 static inline void uda134x_reset(struct snd_soc_codec *codec) 114 135 { 115 - u8 reset_reg = uda134x_read_reg_cache(codec, UDA134X_STATUS0); 116 - uda134x_write(codec, UDA134X_STATUS0, reset_reg | (1<<6)); 136 + struct uda134x_priv *uda134x = snd_soc_codec_get_drvdata(codec); 137 + unsigned int mask = 1<<6; 138 + 139 + regmap_update_bits(uda134x->regmap, UDA134X_STATUS0, mask, mask); 117 140 msleep(1); 118 - uda134x_write(codec, UDA134X_STATUS0, reset_reg & ~(1<<6)); 141 + regmap_update_bits(uda134x->regmap, UDA134X_STATUS0, mask, 0); 119 142 } 120 143 121 144 static int uda134x_mute(struct snd_soc_dai *dai, int mute) 122 145 { 123 - struct snd_soc_codec *codec = dai->codec; 124 - u8 mute_reg = uda134x_read_reg_cache(codec, UDA134X_DATA010); 146 + struct uda134x_priv *uda134x = snd_soc_codec_get_drvdata(dai->codec); 147 + unsigned int mask = 1<<2; 148 + unsigned int val; 125 149 126 150 pr_debug("%s mute: %d\n", __func__, mute); 127 151 128 152 if (mute) 129 - mute_reg |= (1<<2); 153 + val = mask; 130 154 else 131 - mute_reg &= ~(1<<2); 155 + val = 0; 132 156 133 - uda134x_write(codec, UDA134X_DATA010, mute_reg); 134 - 135 - return 0; 157 + return regmap_update_bits(uda134x->regmap, UDA134X_DATA010, mask, val); 136 158 } 137 159 138 160 static int uda134x_startup(struct snd_pcm_substream *substream, ··· 185 205 { 186 206 struct snd_soc_codec *codec = dai->codec; 187 207 struct uda134x_priv *uda134x = snd_soc_codec_get_drvdata(codec); 188 - u8 hw_params; 208 + unsigned int hw_params = 0; 189 209 190 210 if (substream == uda134x->slave_substream) { 191 211 pr_debug("%s ignoring hw_params for slave substream\n", 192 212 __func__); 193 213 return 0; 194 214 } 195 - 196 - hw_params = uda134x_read_reg_cache(codec, UDA134X_STATUS0); 197 - hw_params &= STATUS0_SYSCLK_MASK; 198 - hw_params &= STATUS0_DAIFMT_MASK; 199 215 200 216 pr_debug("%s sysclk: %d, rate:%d\n", __func__, 201 217 uda134x->sysclk, params_rate(params)); ··· 243 267 return -EINVAL; 244 268 } 245 269 246 - uda134x_write(codec, UDA134X_STATUS0, hw_params); 247 - 248 - return 0; 270 + return regmap_update_bits(uda134x->regmap, UDA134X_STATUS0, 271 + STATUS0_SYSCLK_MASK | STATUS0_DAIFMT_MASK, hw_params); 249 272 } 250 273 251 274 static int uda134x_set_dai_sysclk(struct snd_soc_dai *codec_dai, ··· 299 324 static int uda134x_set_bias_level(struct snd_soc_codec *codec, 300 325 enum snd_soc_bias_level level) 301 326 { 302 - struct uda134x_platform_data *pd = codec->control_data; 303 - int i; 304 - u8 *cache = codec->reg_cache; 305 - 327 + struct uda134x_priv *uda134x = snd_soc_codec_get_drvdata(codec); 328 + struct uda134x_platform_data *pd = uda134x->pd; 306 329 pr_debug("%s bias level %d\n", __func__, level); 307 330 308 331 switch (level) { ··· 310 337 /* power on */ 311 338 if (pd->power) { 312 339 pd->power(1); 313 - /* Sync reg_cache with the hardware */ 314 - for (i = 0; i < ARRAY_SIZE(uda134x_reg); i++) 315 - codec->driver->write(codec, i, *cache++); 340 + regcache_sync(uda134x->regmap); 316 341 } 317 342 break; 318 343 case SND_SOC_BIAS_STANDBY: 319 344 break; 320 345 case SND_SOC_BIAS_OFF: 321 346 /* power off */ 322 - if (pd->power) 347 + if (pd->power) { 323 348 pd->power(0); 349 + regcache_mark_dirty(uda134x->regmap); 350 + } 324 351 break; 325 352 } 326 353 return 0; ··· 451 478 static int uda134x_soc_probe(struct snd_soc_codec *codec) 452 479 { 453 480 struct snd_soc_dapm_context *dapm = snd_soc_codec_get_dapm(codec); 454 - struct uda134x_priv *uda134x; 455 - struct uda134x_platform_data *pd = codec->component.card->dev->platform_data; 481 + struct uda134x_priv *uda134x = snd_soc_codec_get_drvdata(codec); 482 + struct uda134x_platform_data *pd = uda134x->pd; 456 483 const struct snd_soc_dapm_widget *widgets; 457 484 unsigned num_widgets; 458 - 459 485 int ret; 460 486 461 487 printk(KERN_INFO "UDA134X SoC Audio Codec\n"); 462 - 463 - if (!pd) { 464 - printk(KERN_ERR "UDA134X SoC codec: " 465 - "missing L3 bitbang function\n"); 466 - return -ENODEV; 467 - } 468 488 469 489 switch (pd->model) { 470 490 case UDA134X_UDA1340: ··· 471 505 pd->model); 472 506 return -EINVAL; 473 507 } 474 - 475 - uda134x = kzalloc(sizeof(struct uda134x_priv), GFP_KERNEL); 476 - if (uda134x == NULL) 477 - return -ENOMEM; 478 - snd_soc_codec_set_drvdata(codec, uda134x); 479 - 480 - codec->control_data = pd; 481 508 482 509 if (pd->power) 483 510 pd->power(1); ··· 489 530 if (ret) { 490 531 printk(KERN_ERR "%s failed to register dapm controls: %d", 491 532 __func__, ret); 492 - kfree(uda134x); 493 533 return ret; 494 534 } 495 535 ··· 509 551 default: 510 552 printk(KERN_ERR "%s unknown codec type: %d", 511 553 __func__, pd->model); 512 - kfree(uda134x); 513 554 return -EINVAL; 514 555 } 515 556 516 557 if (ret < 0) { 517 558 printk(KERN_ERR "UDA134X: failed to register controls\n"); 518 - kfree(uda134x); 519 559 return ret; 520 560 } 521 561 522 562 return 0; 523 563 } 524 564 525 - /* power down chip */ 526 - static int uda134x_soc_remove(struct snd_soc_codec *codec) 527 - { 528 - struct uda134x_priv *uda134x = snd_soc_codec_get_drvdata(codec); 529 - 530 - kfree(uda134x); 531 - return 0; 532 - } 533 - 534 565 static struct snd_soc_codec_driver soc_codec_dev_uda134x = { 535 566 .probe = uda134x_soc_probe, 536 - .remove = uda134x_soc_remove, 537 - .reg_cache_size = sizeof(uda134x_reg), 538 - .reg_word_size = sizeof(u8), 539 - .reg_cache_default = uda134x_reg, 540 - .reg_cache_step = 1, 541 - .read = uda134x_read_reg_cache, 542 567 .set_bias_level = uda134x_set_bias_level, 543 568 .suspend_bias_off = true, 544 569 ··· 531 590 .num_dapm_routes = ARRAY_SIZE(uda134x_dapm_routes), 532 591 }; 533 592 593 + static const struct regmap_config uda134x_regmap_config = { 594 + .reg_bits = 8, 595 + .val_bits = 8, 596 + .max_register = UDA134X_DATA1, 597 + .reg_defaults = uda134x_reg_defaults, 598 + .num_reg_defaults = ARRAY_SIZE(uda134x_reg_defaults), 599 + .cache_type = REGCACHE_RBTREE, 600 + 601 + .reg_write = uda134x_regmap_write, 602 + }; 603 + 534 604 static int uda134x_codec_probe(struct platform_device *pdev) 535 605 { 606 + struct uda134x_platform_data *pd = pdev->dev.platform_data; 607 + struct uda134x_priv *uda134x; 608 + 609 + if (!pd) { 610 + dev_err(&pdev->dev, "Missing L3 bitbang function\n"); 611 + return -ENODEV; 612 + } 613 + 614 + uda134x = devm_kzalloc(&pdev->dev, sizeof(*uda134x), GFP_KERNEL); 615 + if (!uda134x) 616 + return -ENOMEM; 617 + 618 + uda134x->pd = pd; 619 + platform_set_drvdata(pdev, uda134x); 620 + 621 + uda134x->regmap = devm_regmap_init(&pdev->dev, NULL, pd, 622 + &uda134x_regmap_config); 623 + if (IS_ERR(uda134x->regmap)) 624 + return PTR_ERR(uda134x->regmap); 625 + 536 626 return snd_soc_register_codec(&pdev->dev, 537 627 &soc_codec_dev_uda134x, &uda134x_dai, 1); 538 628 }
-2
sound/soc/codecs/uda134x.h
··· 26 26 #define UDA134X_DATA011 13 27 27 #define UDA134X_DATA1 14 28 28 29 - #define UDA134X_REGS_NUM 15 30 - 31 29 #define STATUS0_DAIFMT_MASK (~(7<<1)) 32 30 #define STATUS0_SYSCLK_MASK (~(3<<4)) 33 31
+1 -1
sound/soc/codecs/wm2200.c
··· 1702 1702 int *bclk_rates; 1703 1703 1704 1704 /* Data sizes if not using TDM */ 1705 - wl = snd_pcm_format_width(params_format(params)); 1705 + wl = params_width(params); 1706 1706 if (wl < 0) 1707 1707 return wl; 1708 1708 fl = snd_soc_params_to_frame_size(params);
+1 -1
sound/soc/codecs/wm5100.c
··· 1408 1408 base = dai->driver->base; 1409 1409 1410 1410 /* Data sizes if not using TDM */ 1411 - wl = snd_pcm_format_width(params_format(params)); 1411 + wl = params_width(params); 1412 1412 if (wl < 0) 1413 1413 return wl; 1414 1414 fl = snd_soc_params_to_frame_size(params);
+2 -2
sound/soc/codecs/wm8776.c
··· 265 265 } 266 266 267 267 /* Set word length */ 268 - switch (snd_pcm_format_width(params_format(params))) { 268 + switch (params_width(params)) { 269 269 case 16: 270 270 iface = 0; 271 271 break; ··· 280 280 break; 281 281 default: 282 282 dev_err(codec->dev, "Unsupported sample size: %i\n", 283 - snd_pcm_format_width(params_format(params))); 283 + params_width(params)); 284 284 return -EINVAL; 285 285 } 286 286
+1 -1
sound/soc/codecs/wm8996.c
··· 1780 1780 wm8996->rx_rate[dai->id] = params_rate(params); 1781 1781 1782 1782 /* Needs looking at for TDM */ 1783 - bits = snd_pcm_format_width(params_format(params)); 1783 + bits = params_width(params); 1784 1784 if (bits < 0) 1785 1785 return bits; 1786 1786 aifdata |= (bits << WM8996_AIF1TX_WL_SHIFT) | bits;
+2 -8
sound/soc/txx9/txx9aclc.c
··· 411 411 412 412 static int txx9aclc_soc_platform_probe(struct platform_device *pdev) 413 413 { 414 - return snd_soc_register_platform(&pdev->dev, &txx9aclc_soc_platform); 415 - } 416 - 417 - static int txx9aclc_soc_platform_remove(struct platform_device *pdev) 418 - { 419 - snd_soc_unregister_platform(&pdev->dev); 420 - return 0; 414 + return devm_snd_soc_register_platform(&pdev->dev, 415 + &txx9aclc_soc_platform); 421 416 } 422 417 423 418 static struct platform_driver txx9aclc_pcm_driver = { ··· 421 426 }, 422 427 423 428 .probe = txx9aclc_soc_platform_probe, 424 - .remove = txx9aclc_soc_platform_remove, 425 429 }; 426 430 427 431 module_platform_driver(txx9aclc_pcm_driver);
+10 -19
sound/soc/ux500/ux500_msp_dai.c
··· 773 773 } 774 774 prcmu_qos_add_requirement(PRCMU_QOS_APE_OPP, (char *)pdev->name, 50); 775 775 776 - drvdata->pclk = clk_get(&pdev->dev, "apb_pclk"); 776 + drvdata->pclk = devm_clk_get(&pdev->dev, "apb_pclk"); 777 777 if (IS_ERR(drvdata->pclk)) { 778 778 ret = (int)PTR_ERR(drvdata->pclk); 779 - dev_err(&pdev->dev, "%s: ERROR: clk_get of pclk failed (%d)!\n", 779 + dev_err(&pdev->dev, 780 + "%s: ERROR: devm_clk_get of pclk failed (%d)!\n", 780 781 __func__, ret); 781 - goto err_pclk; 782 + return ret; 782 783 } 783 784 784 - drvdata->clk = clk_get(&pdev->dev, NULL); 785 + drvdata->clk = devm_clk_get(&pdev->dev, NULL); 785 786 if (IS_ERR(drvdata->clk)) { 786 787 ret = (int)PTR_ERR(drvdata->clk); 787 - dev_err(&pdev->dev, "%s: ERROR: clk_get failed (%d)!\n", 788 + dev_err(&pdev->dev, 789 + "%s: ERROR: devm_clk_get failed (%d)!\n", 788 790 __func__, ret); 789 - goto err_clk; 791 + return ret; 790 792 } 791 793 792 794 ret = ux500_msp_i2s_init_msp(pdev, &drvdata->msp, ··· 797 795 dev_err(&pdev->dev, 798 796 "%s: ERROR: Failed to init MSP-struct (%d)!", 799 797 __func__, ret); 800 - goto err_init_msp; 798 + return ret; 801 799 } 802 800 dev_set_drvdata(&pdev->dev, drvdata); 803 801 ··· 806 804 if (ret < 0) { 807 805 dev_err(&pdev->dev, "Error: %s: Failed to register MSP%d!\n", 808 806 __func__, drvdata->msp->id); 809 - goto err_init_msp; 807 + return ret; 810 808 } 811 809 812 810 ret = ux500_pcm_register_platform(pdev); ··· 821 819 822 820 err_reg_plat: 823 821 snd_soc_unregister_component(&pdev->dev); 824 - err_init_msp: 825 - clk_put(drvdata->clk); 826 - err_clk: 827 - clk_put(drvdata->pclk); 828 - err_pclk: 829 - devm_regulator_put(drvdata->reg_vape); 830 - 831 822 return ret; 832 823 } 833 824 ··· 832 837 833 838 snd_soc_unregister_component(&pdev->dev); 834 839 835 - devm_regulator_put(drvdata->reg_vape); 836 840 prcmu_qos_remove_requirement(PRCMU_QOS_APE_OPP, "ux500_msp_i2s"); 837 - 838 - clk_put(drvdata->clk); 839 - clk_put(drvdata->pclk); 840 841 841 842 ux500_msp_i2s_cleanup_msp(pdev, drvdata->msp); 842 843