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

ASoC: hdmi-codec: merge .digital_mute() into .mute_stream()

snd_soc_dai_digital_mute() is internally using both
mute_stream() (1) or digital_mute() (2), but the difference between
these 2 are only handling direction.
We can merge digital_mute() into mute_stream

int snd_soc_dai_digital_mute(xxx, int direction)
{
...
else if (dai->driver->ops->mute_stream)
(1) return dai->driver->ops->mute_stream(xxx, direction);
else if (direction == SNDRV_PCM_STREAM_PLAYBACK &&
dai->driver->ops->digital_mute)
(2) return dai->driver->ops->digital_mute(xxx);
...
}

For hdmi-codec, we need to update struct hdmi_codec_ops,
and all its users in the same time.

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Reviewed-by: Peter Ujfalusi <peter.ujfalusi@ti.com>
Link: https://lore.kernel.org/r/87d055xxj2.wl-kuninori.morimoto.gx@renesas.com
Signed-off-by: Mark Brown <broonie@kernel.org>

authored by

Kuninori Morimoto and committed by
Mark Brown
d789710f 350d9935

+48 -25
+4 -3
drivers/gpu/drm/bridge/sii902x.c
··· 672 672 clk_disable_unprepare(sii902x->audio.mclk); 673 673 } 674 674 675 - static int sii902x_audio_digital_mute(struct device *dev, 676 - void *data, bool enable) 675 + static int sii902x_audio_mute(struct device *dev, void *data, 676 + bool enable, int direction) 677 677 { 678 678 struct sii902x *sii902x = dev_get_drvdata(dev); 679 679 ··· 724 724 static const struct hdmi_codec_ops sii902x_audio_codec_ops = { 725 725 .hw_params = sii902x_audio_hw_params, 726 726 .audio_shutdown = sii902x_audio_shutdown, 727 - .digital_mute = sii902x_audio_digital_mute, 727 + .mute_stream = sii902x_audio_mute, 728 728 .get_eld = sii902x_audio_get_eld, 729 729 .get_dai_id = sii902x_audio_get_dai_id, 730 + .no_capture_mute = 1, 730 731 }; 731 732 732 733 static int sii902x_audio_codec_init(struct sii902x *sii902x,
+4 -2
drivers/gpu/drm/exynos/exynos_hdmi.c
··· 1604 1604 return 0; 1605 1605 } 1606 1606 1607 - static int hdmi_audio_digital_mute(struct device *dev, void *data, bool mute) 1607 + static int hdmi_audio_mute(struct device *dev, void *data, 1608 + bool mute, int direction) 1608 1609 { 1609 1610 struct hdmi_context *hdata = dev_get_drvdata(dev); 1610 1611 ··· 1635 1634 static const struct hdmi_codec_ops audio_codec_ops = { 1636 1635 .hw_params = hdmi_audio_hw_params, 1637 1636 .audio_shutdown = hdmi_audio_shutdown, 1638 - .digital_mute = hdmi_audio_digital_mute, 1637 + .mute_stream = hdmi_audio_mute, 1639 1638 .get_eld = hdmi_audio_get_eld, 1639 + .no_capture_mute = 1, 1640 1640 }; 1641 1641 1642 1642 static int hdmi_register_audio_device(struct hdmi_context *hdata)
+4 -3
drivers/gpu/drm/i2c/tda998x_drv.c
··· 1133 1133 mutex_unlock(&priv->audio_mutex); 1134 1134 } 1135 1135 1136 - static int tda998x_audio_digital_mute(struct device *dev, void *data, 1137 - bool enable) 1136 + static int tda998x_audio_mute_stream(struct device *dev, void *data, 1137 + bool enable, int direction) 1138 1138 { 1139 1139 struct tda998x_priv *priv = dev_get_drvdata(dev); 1140 1140 ··· 1162 1162 static const struct hdmi_codec_ops audio_codec_ops = { 1163 1163 .hw_params = tda998x_audio_hw_params, 1164 1164 .audio_shutdown = tda998x_audio_shutdown, 1165 - .digital_mute = tda998x_audio_digital_mute, 1165 + .mute_stream = tda998x_audio_mute_stream, 1166 1166 .get_eld = tda998x_audio_get_eld, 1167 + .no_capture_mute = 1, 1167 1168 }; 1168 1169 1169 1170 static int tda998x_audio_codec_init(struct tda998x_priv *priv,
+4 -2
drivers/gpu/drm/mediatek/mtk_hdmi.c
··· 1647 1647 } 1648 1648 1649 1649 static int 1650 - mtk_hdmi_audio_digital_mute(struct device *dev, void *data, bool enable) 1650 + mtk_hdmi_audio_mute(struct device *dev, void *data, 1651 + bool enable, int direction) 1651 1652 { 1652 1653 struct mtk_hdmi *hdmi = dev_get_drvdata(dev); 1653 1654 ··· 1693 1692 .hw_params = mtk_hdmi_audio_hw_params, 1694 1693 .audio_startup = mtk_hdmi_audio_startup, 1695 1694 .audio_shutdown = mtk_hdmi_audio_shutdown, 1696 - .digital_mute = mtk_hdmi_audio_digital_mute, 1695 + .mute_stream = mtk_hdmi_audio_mute, 1697 1696 .get_eld = mtk_hdmi_audio_get_eld, 1698 1697 .hook_plugged_cb = mtk_hdmi_audio_hook_plugged_cb, 1698 + .no_capture_mute = 1, 1699 1699 }; 1700 1700 1701 1701 static int mtk_hdmi_register_audio_driver(struct device *dev)
+4 -3
drivers/gpu/drm/rockchip/cdn-dp-core.c
··· 817 817 mutex_unlock(&dp->lock); 818 818 } 819 819 820 - static int cdn_dp_audio_digital_mute(struct device *dev, void *data, 821 - bool enable) 820 + static int cdn_dp_audio_mute_stream(struct device *dev, void *data, 821 + bool enable, int direction) 822 822 { 823 823 struct cdn_dp_device *dp = dev_get_drvdata(dev); 824 824 int ret; ··· 849 849 static const struct hdmi_codec_ops audio_codec_ops = { 850 850 .hw_params = cdn_dp_audio_hw_params, 851 851 .audio_shutdown = cdn_dp_audio_shutdown, 852 - .digital_mute = cdn_dp_audio_digital_mute, 852 + .mute_stream = cdn_dp_audio_mute_stream, 853 853 .get_eld = cdn_dp_audio_get_eld, 854 + .no_capture_mute = 1, 854 855 }; 855 856 856 857 static int cdn_dp_audio_codec_init(struct cdn_dp_device *dp,
+4 -2
drivers/gpu/drm/sti/sti_hdmi.c
··· 1191 1191 return 0; 1192 1192 } 1193 1193 1194 - static int hdmi_audio_digital_mute(struct device *dev, void *data, bool enable) 1194 + static int hdmi_audio_mute(struct device *dev, void *data, 1195 + bool enable, int direction) 1195 1196 { 1196 1197 struct sti_hdmi *hdmi = dev_get_drvdata(dev); 1197 1198 ··· 1220 1219 static const struct hdmi_codec_ops audio_codec_ops = { 1221 1220 .hw_params = hdmi_audio_hw_params, 1222 1221 .audio_shutdown = hdmi_audio_shutdown, 1223 - .digital_mute = hdmi_audio_digital_mute, 1222 + .mute_stream = hdmi_audio_mute, 1224 1223 .get_eld = hdmi_audio_get_eld, 1224 + .no_capture_mute = 1, 1225 1225 }; 1226 1226 1227 1227 static int sti_hdmi_register_audio_driver(struct device *dev,
+4 -3
drivers/gpu/drm/zte/zx_hdmi.c
··· 439 439 return zx_hdmi_infoframe_trans(hdmi, &frame, FSEL_AUDIO); 440 440 } 441 441 442 - static int zx_hdmi_audio_digital_mute(struct device *dev, void *data, 443 - bool enable) 442 + static int zx_hdmi_audio_mute(struct device *dev, void *data, 443 + bool enable, int direction) 444 444 { 445 445 struct zx_hdmi *hdmi = dev_get_drvdata(dev); 446 446 ··· 468 468 .audio_startup = zx_hdmi_audio_startup, 469 469 .hw_params = zx_hdmi_audio_hw_params, 470 470 .audio_shutdown = zx_hdmi_audio_shutdown, 471 - .digital_mute = zx_hdmi_audio_digital_mute, 471 + .mute_stream = zx_hdmi_audio_mute, 472 472 .get_eld = zx_hdmi_audio_get_eld, 473 + .no_capture_mute = 1, 473 474 }; 474 475 475 476 static struct hdmi_codec_pdata zx_hdmi_codec_pdata = {
+5 -1
include/sound/hdmi-codec.h
··· 76 76 * Mute/unmute HDMI audio stream. 77 77 * Optional 78 78 */ 79 - int (*digital_mute)(struct device *dev, void *data, bool enable); 79 + int (*mute_stream)(struct device *dev, void *data, 80 + bool enable, int direction); 80 81 81 82 /* 82 83 * Provides EDID-Like-Data from connected HDMI device. ··· 100 99 int (*hook_plugged_cb)(struct device *dev, void *data, 101 100 hdmi_codec_plugged_cb fn, 102 101 struct device *codec_dev); 102 + 103 + /* bit field */ 104 + unsigned int no_capture_mute:1; 103 105 }; 104 106 105 107 /* HDMI codec initalization data */
+15 -6
sound/soc/codecs/hdmi-codec.c
··· 558 558 return 0; 559 559 } 560 560 561 - static int hdmi_codec_digital_mute(struct snd_soc_dai *dai, int mute) 561 + static int hdmi_codec_mute(struct snd_soc_dai *dai, int mute, int direction) 562 562 { 563 563 struct hdmi_codec_priv *hcp = snd_soc_dai_get_drvdata(dai); 564 564 565 - if (hcp->hcd.ops->digital_mute) 566 - return hcp->hcd.ops->digital_mute(dai->dev->parent, 567 - hcp->hcd.data, mute); 565 + /* 566 + * ignore if direction was CAPTURE 567 + * and it had .no_capture_mute flag 568 + * see 569 + * snd_soc_dai_digital_mute() 570 + */ 571 + if (hcp->hcd.ops->mute_stream && 572 + (direction == SNDRV_PCM_STREAM_PLAYBACK || 573 + !hcp->hcd.ops->no_capture_mute)) 574 + return hcp->hcd.ops->mute_stream(dai->dev->parent, 575 + hcp->hcd.data, 576 + mute, direction); 568 577 569 578 return -ENOTSUPP; 570 579 } ··· 583 574 .shutdown = hdmi_codec_shutdown, 584 575 .hw_params = hdmi_codec_hw_params, 585 576 .set_fmt = hdmi_codec_i2s_set_fmt, 586 - .digital_mute = hdmi_codec_digital_mute, 577 + .mute_stream = hdmi_codec_mute, 587 578 }; 588 579 589 580 static const struct snd_soc_dai_ops hdmi_codec_spdif_dai_ops = { 590 581 .startup = hdmi_codec_startup, 591 582 .shutdown = hdmi_codec_shutdown, 592 583 .hw_params = hdmi_codec_hw_params, 593 - .digital_mute = hdmi_codec_digital_mute, 584 + .mute_stream = hdmi_codec_mute, 594 585 }; 595 586 596 587 #define HDMI_RATES (SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_44100 |\