.. | .. |
---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-only |
---|
1 | 2 | /* |
---|
2 | 3 | * rt274.c -- RT274 ALSA SoC audio codec driver |
---|
3 | 4 | * |
---|
4 | 5 | * Copyright 2017 Realtek Semiconductor Corp. |
---|
5 | 6 | * Author: Bard Liao <bardliao@realtek.com> |
---|
6 | | - * |
---|
7 | | - * This program is free software; you can redistribute it and/or modify |
---|
8 | | - * it under the terms of the GNU General Public License version 2 as |
---|
9 | | - * published by the Free Software Foundation. |
---|
10 | 7 | */ |
---|
11 | 8 | |
---|
12 | 9 | #include <linux/module.h> |
---|
.. | .. |
---|
353 | 350 | static int rt274_jack_detect(struct rt274_priv *rt274, bool *hp, bool *mic) |
---|
354 | 351 | { |
---|
355 | 352 | unsigned int buf; |
---|
| 353 | + int ret; |
---|
356 | 354 | |
---|
357 | 355 | *hp = false; |
---|
358 | 356 | *mic = false; |
---|
.. | .. |
---|
360 | 358 | if (!rt274->component) |
---|
361 | 359 | return -EINVAL; |
---|
362 | 360 | |
---|
363 | | - regmap_read(rt274->regmap, RT274_GET_HP_SENSE, &buf); |
---|
| 361 | + ret = regmap_read(rt274->regmap, RT274_GET_HP_SENSE, &buf); |
---|
| 362 | + if (ret) |
---|
| 363 | + return ret; |
---|
| 364 | + |
---|
364 | 365 | *hp = buf & 0x80000000; |
---|
365 | | - regmap_read(rt274->regmap, RT274_GET_MIC_SENSE, &buf); |
---|
| 366 | + ret = regmap_read(rt274->regmap, RT274_GET_MIC_SENSE, &buf); |
---|
| 367 | + if (ret) |
---|
| 368 | + return ret; |
---|
| 369 | + |
---|
366 | 370 | *mic = buf & 0x80000000; |
---|
367 | 371 | |
---|
368 | 372 | pr_debug("*hp = %d *mic = %d\n", *hp, *mic); |
---|
.. | .. |
---|
381 | 385 | if (rt274_jack_detect(rt274, &hp, &mic) < 0) |
---|
382 | 386 | return; |
---|
383 | 387 | |
---|
384 | | - if (hp == true) |
---|
| 388 | + if (hp) |
---|
385 | 389 | status |= SND_JACK_HEADPHONE; |
---|
386 | 390 | |
---|
387 | | - if (mic == true) |
---|
| 391 | + if (mic) |
---|
388 | 392 | status |= SND_JACK_MICROPHONE; |
---|
389 | 393 | |
---|
390 | 394 | snd_soc_jack_report(rt274->jack, status, |
---|
.. | .. |
---|
756 | 760 | break; |
---|
757 | 761 | default: |
---|
758 | 762 | dev_warn(component->dev, "invalid pll source, use BCLK\n"); |
---|
| 763 | + fallthrough; |
---|
759 | 764 | case RT274_PLL2_S_BCLK: |
---|
760 | 765 | snd_soc_component_update_bits(component, RT274_PLL2_CTRL, |
---|
761 | 766 | RT274_PLL2_SRC_MASK, RT274_PLL2_SRC_BCLK); |
---|
.. | .. |
---|
783 | 788 | break; |
---|
784 | 789 | default: |
---|
785 | 790 | dev_warn(component->dev, "invalid freq_in, assume 4.8M\n"); |
---|
| 791 | + fallthrough; |
---|
786 | 792 | case 100: |
---|
787 | 793 | snd_soc_component_write(component, 0x7a, 0xaab6); |
---|
788 | 794 | snd_soc_component_write(component, 0x7b, 0x0301); |
---|
.. | .. |
---|
954 | 960 | ret = rt274_jack_detect(rt274, &hp, &mic); |
---|
955 | 961 | |
---|
956 | 962 | if (ret == 0) { |
---|
957 | | - if (hp == true) |
---|
| 963 | + if (hp) |
---|
958 | 964 | status |= SND_JACK_HEADPHONE; |
---|
959 | 965 | |
---|
960 | | - if (mic == true) |
---|
| 966 | + if (mic) |
---|
961 | 967 | status |= SND_JACK_MICROPHONE; |
---|
962 | 968 | |
---|
963 | 969 | snd_soc_jack_report(rt274->jack, status, |
---|
.. | .. |
---|
1099 | 1105 | }; |
---|
1100 | 1106 | MODULE_DEVICE_TABLE(i2c, rt274_i2c_id); |
---|
1101 | 1107 | |
---|
| 1108 | +#ifdef CONFIG_ACPI |
---|
1102 | 1109 | static const struct acpi_device_id rt274_acpi_match[] = { |
---|
1103 | 1110 | { "10EC0274", 0 }, |
---|
1104 | 1111 | { "INT34C2", 0 }, |
---|
1105 | 1112 | {}, |
---|
1106 | 1113 | }; |
---|
1107 | 1114 | MODULE_DEVICE_TABLE(acpi, rt274_acpi_match); |
---|
| 1115 | +#endif |
---|
1108 | 1116 | |
---|
1109 | 1117 | static int rt274_i2c_probe(struct i2c_client *i2c, |
---|
1110 | 1118 | const struct i2c_device_id *id) |
---|