ASoC: codec: Update codec driver to component driver

Some alsa API are removed in kernel-4.19 which would cause
codec driver compile failure. Update codec driver to fix it.

Change-Id: Ie358ec1863082166958059c179300b453d2a03ad
Signed-off-by: Meng Wang <mengw@codeaurora.org>
This commit is contained in:
Meng Wang
2018-09-06 10:49:18 +08:00
committed by Gerrit - the friendly Code Review server
parent ee084a068e
commit 15c825d077
59 changed files with 8532 additions and 6916 deletions

View File

@@ -11,6 +11,8 @@
#include <sound/soc.h>
#include <linux/msm_ext_display.h>
#define DRV_NAME "HDMI_codec"
#define MSM_EXT_DISP_PCM_RATES SNDRV_PCM_RATE_48000
#define AUD_EXT_DISP_ACK_DISCONNECT (AUDIO_ACK_CONNECT ^ AUDIO_ACK_CONNECT)
#define AUD_EXT_DISP_ACK_CONNECT (AUDIO_ACK_CONNECT)
@@ -64,29 +66,30 @@ struct msm_ext_disp_audio_codec_rx_data {
static int msm_ext_disp_edid_ctl_info(struct snd_kcontrol *kcontrol,
struct snd_ctl_elem_info *uinfo)
{
struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
struct snd_soc_component *component =
snd_soc_kcontrol_component(kcontrol);
struct msm_ext_disp_audio_codec_rx_data *codec_data;
struct msm_ext_disp_audio_edid_blk edid_blk;
int rc = 0;
struct msm_ext_disp_codec_id codec_info;
int dai_id = kcontrol->private_value;
codec_data = snd_soc_codec_get_drvdata(codec);
codec_data = snd_soc_component_get_drvdata(component);
if (!codec_data) {
dev_err(codec->dev, "%s: codec_data is NULL\n", __func__);
dev_err(component->dev, "%s: codec_data is NULL\n", __func__);
return -EINVAL;
}
if (!codec_data->ext_disp_ops.get_audio_edid_blk) {
dev_dbg(codec->dev, "%s: get_audio_edid_blk() is NULL\n",
dev_dbg(component->dev, "%s: get_audio_edid_blk() is NULL\n",
__func__);
uinfo->type = SNDRV_CTL_ELEM_TYPE_BYTES;
uinfo->count = 0;
return 0;
}
dev_dbg(codec->dev, "%s: DP ctl id %d Stream id %d\n", __func__,
dev_dbg(component->dev, "%s: DP ctl id %d Stream id %d\n", __func__,
codec_data->ctl[dai_id], codec_data->stream[dai_id]);
mutex_lock(&codec_data->dp_ops_lock);
@@ -100,28 +103,29 @@ static int msm_ext_disp_edid_ctl_info(struct snd_kcontrol *kcontrol,
edid_blk.spk_alloc_data_blk_size;
}
dev_dbg(codec->dev, "%s: count: %d\n", __func__, uinfo->count);
dev_dbg(component->dev, "%s: count: %d\n", __func__, uinfo->count);
return rc;
}
static int msm_ext_disp_edid_get(struct snd_kcontrol *kcontrol,
struct snd_ctl_elem_value *ucontrol) {
struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
struct snd_soc_component *component =
snd_soc_kcontrol_component(kcontrol);
struct msm_ext_disp_audio_codec_rx_data *codec_data;
struct msm_ext_disp_audio_edid_blk edid_blk;
struct msm_ext_disp_codec_id codec_info;
int rc = 0;
int dai_id = kcontrol->private_value;
codec_data = snd_soc_codec_get_drvdata(codec);
codec_data = snd_soc_component_get_drvdata(component);
if (!codec_data || !codec_data->ext_disp_ops.get_audio_edid_blk) {
dev_err(codec->dev, "%s: codec_data or get_audio_edid_blk() is NULL\n",
dev_err(component->dev, "%s: codec_data or get_audio_edid_blk() is NULL\n",
__func__);
return -EINVAL;
}
dev_dbg(codec->dev, "%s: DP ctl id %d Stream id %d\n", __func__,
dev_dbg(component->dev, "%s: DP ctl id %d Stream id %d\n", __func__,
codec_data->ctl[dai_id], codec_data->stream[dai_id]);
mutex_lock(&codec_data->dp_ops_lock);
@@ -133,7 +137,7 @@ static int msm_ext_disp_edid_get(struct snd_kcontrol *kcontrol,
if (sizeof(ucontrol->value.bytes.data) <
(edid_blk.audio_data_blk_size +
edid_blk.spk_alloc_data_blk_size)) {
dev_err(codec->dev,
dev_err(component->dev,
"%s: Not enough memory to copy EDID data\n",
__func__);
return -ENOMEM;
@@ -147,7 +151,7 @@ static int msm_ext_disp_edid_get(struct snd_kcontrol *kcontrol,
edid_blk.spk_alloc_data_blk,
edid_blk.spk_alloc_data_blk_size);
dev_dbg(codec->dev, "%s: data_blk_size:%d, spk_alloc_data_blk_size:%d\n",
dev_dbg(component->dev, "%s: data_blk_size:%d, spk_alloc_data_blk_size:%d\n",
__func__, edid_blk.audio_data_blk_size,
edid_blk.spk_alloc_data_blk_size);
}
@@ -158,7 +162,8 @@ static int msm_ext_disp_edid_get(struct snd_kcontrol *kcontrol,
static int msm_ext_disp_audio_type_get(struct snd_kcontrol *kcontrol,
struct snd_ctl_elem_value *ucontrol)
{
struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
struct snd_soc_component *component =
snd_soc_kcontrol_component(kcontrol);
struct msm_ext_disp_audio_codec_rx_data *codec_data;
enum msm_ext_disp_cable_state cable_state;
enum msm_ext_disp_type disp_type;
@@ -166,16 +171,16 @@ static int msm_ext_disp_audio_type_get(struct snd_kcontrol *kcontrol,
int rc = 0;
int dai_id = ((struct soc_enum *) kcontrol->private_value)->shift_l;
codec_data = snd_soc_codec_get_drvdata(codec);
codec_data = snd_soc_component_get_drvdata(component);
if (!codec_data ||
!codec_data->ext_disp_ops.get_audio_edid_blk ||
!codec_data->ext_disp_ops.get_intf_id) {
dev_err(codec->dev, "%s: codec_data, get_audio_edid_blk() or get_intf_id is NULL\n",
dev_err(component->dev, "%s: codec_data, get_audio_edid_blk() or get_intf_id is NULL\n",
__func__);
return -EINVAL;
}
dev_dbg(codec->dev, "%s: DP ctl id %d Stream id %d\n", __func__,
dev_dbg(component->dev, "%s: DP ctl id %d Stream id %d\n", __func__,
codec_data->ctl[dai_id], codec_data->stream[dai_id]);
mutex_lock(&codec_data->dp_ops_lock);
@@ -183,7 +188,7 @@ static int msm_ext_disp_audio_type_get(struct snd_kcontrol *kcontrol,
cable_state = codec_data->ext_disp_ops.cable_status(
codec_data->ext_disp_core_pdev, 1);
if (cable_state < 0) {
dev_err(codec->dev, "%s: Error retrieving cable state from ext_disp, err:%d\n",
dev_err(component->dev, "%s: Error retrieving cable state from ext_disp, err:%d\n",
__func__, cable_state);
rc = cable_state;
goto cable_err;
@@ -191,7 +196,7 @@ static int msm_ext_disp_audio_type_get(struct snd_kcontrol *kcontrol,
codec_data->cable_status = cable_state;
if (cable_state == EXT_DISPLAY_CABLE_DISCONNECT) {
dev_err(codec->dev, "%s: Display cable disconnected\n",
dev_err(component->dev, "%s: Display cable disconnected\n",
__func__);
ucontrol->value.integer.value[0] = 0;
rc = 0;
@@ -213,14 +218,14 @@ static int msm_ext_disp_audio_type_get(struct snd_kcontrol *kcontrol,
break;
default:
rc = -EINVAL;
dev_err(codec->dev, "%s: Invalid disp_type:%d\n",
dev_err(component->dev, "%s: Invalid disp_type:%d\n",
__func__, disp_type);
goto done;
}
dev_dbg(codec->dev, "%s: Display type: %d\n",
dev_dbg(component->dev, "%s: Display type: %d\n",
__func__, disp_type);
} else {
dev_err(codec->dev, "%s: Error retrieving disp_type from ext_disp, err:%d\n",
dev_err(component->dev, "%s: Error retrieving disp_type from ext_disp, err:%d\n",
__func__, disp_type);
rc = disp_type;
}
@@ -235,24 +240,25 @@ done:
static int msm_ext_disp_audio_ack_set(struct snd_kcontrol *kcontrol,
struct snd_ctl_elem_value *ucontrol)
{
struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
struct snd_soc_component *component =
snd_soc_kcontrol_component(kcontrol);
struct msm_ext_disp_audio_codec_rx_data *codec_data;
u32 ack_state = 0;
struct msm_ext_disp_codec_id codec_info;
int rc = 0;
int dai_id = ((struct soc_enum *) kcontrol->private_value)->shift_l;
codec_data = snd_soc_codec_get_drvdata(codec);
codec_data = snd_soc_component_get_drvdata(component);
if (!codec_data ||
!codec_data->ext_disp_ops.acknowledge) {
dev_err(codec->dev,
dev_err(component->dev,
"%s: codec_data or ops acknowledge() is NULL\n",
__func__);
rc = -EINVAL;
goto done;
}
dev_dbg(codec->dev, "%s: DP ctl id %d Stream id %d\n", __func__,
dev_dbg(component->dev, "%s: DP ctl id %d Stream id %d\n", __func__,
codec_data->ctl[dai_id], codec_data->stream[dai_id]);
switch (ucontrol->value.enumerated.item[0]) {
@@ -267,12 +273,12 @@ static int msm_ext_disp_audio_ack_set(struct snd_kcontrol *kcontrol,
break;
default:
rc = -EINVAL;
dev_err(codec->dev,
dev_err(component->dev,
"%s: invalid value %d for mixer ctl\n",
__func__, ucontrol->value.enumerated.item[0]);
goto done;
}
dev_dbg(codec->dev, "%s: control %d, ack set value 0x%x\n",
dev_dbg(component->dev, "%s: control %d, ack set value 0x%x\n",
__func__, ucontrol->value.enumerated.item[0], ack_state);
mutex_lock(&codec_data->dp_ops_lock);
@@ -281,7 +287,7 @@ static int msm_ext_disp_audio_ack_set(struct snd_kcontrol *kcontrol,
codec_data->ext_disp_core_pdev, ack_state);
mutex_unlock(&codec_data->dp_ops_lock);
if (rc < 0) {
dev_err(codec->dev, "%s: error from acknowledge(), err:%d\n",
dev_err(component->dev, "%s: error from acknowledge(), err:%d\n",
__func__, rc);
}
@@ -292,14 +298,15 @@ done:
static int msm_ext_disp_audio_device_set(struct snd_kcontrol *kcontrol,
struct snd_ctl_elem_value *ucontrol)
{
struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
struct snd_soc_component *component =
snd_soc_kcontrol_component(kcontrol);
struct msm_ext_disp_audio_codec_rx_data *codec_data;
int rc = 0;
int dai_id = ((struct soc_enum *) kcontrol->private_value)->shift_l;
codec_data = snd_soc_codec_get_drvdata(codec);
codec_data = snd_soc_component_get_drvdata(component);
if (!codec_data) {
dev_err(codec->dev,
dev_err(component->dev,
"%s: codec_data or ops acknowledge() is NULL\n",
__func__);
rc = -EINVAL;
@@ -371,7 +378,7 @@ static int msm_ext_disp_audio_codec_rx_dai_startup(
int ret = 0;
struct msm_ext_disp_codec_id codec_info;
struct msm_ext_disp_audio_codec_rx_data *codec_data =
dev_get_drvdata(dai->codec->dev);
dev_get_drvdata(dai->component->dev);
if (!codec_data || !codec_data->ext_disp_ops.cable_status) {
dev_err(dai->dev, "%s() codec_data or cable_status is null\n",
@@ -379,7 +386,8 @@ static int msm_ext_disp_audio_codec_rx_dai_startup(
return -EINVAL;
}
dev_dbg(dai->codec->dev, "%s: DP ctl id %d Stream id %d\n", __func__,
dev_dbg(dai->component->dev, "%s: DP ctl id %d Stream id %d\n",
__func__,
codec_data->ctl[dai->id], codec_data->stream[dai->id]);
mutex_lock(&codec_data->dp_ops_lock);
@@ -417,7 +425,7 @@ static int msm_ext_disp_audio_codec_rx_dai_hw_params(
struct msm_ext_disp_audio_setup_params audio_setup_params = {0};
struct msm_ext_disp_audio_codec_rx_data *codec_data =
dev_get_drvdata(dai->codec->dev);
dev_get_drvdata(dai->component->dev);
if (!codec_data || !codec_data->ext_disp_ops.audio_info_setup) {
dev_err(dai->dev, "%s: codec_data or audio_info_setup is null\n",
@@ -425,7 +433,8 @@ static int msm_ext_disp_audio_codec_rx_dai_hw_params(
return -EINVAL;
}
dev_dbg(dai->codec->dev, "%s: DP ctl id %d Stream id %d\n", __func__,
dev_dbg(dai->component->dev, "%s: DP ctl id %d Stream id %d\n",
__func__,
codec_data->ctl[dai->id], codec_data->stream[dai->id]);
if (codec_data->cable_status < 0) {
@@ -507,7 +516,7 @@ static void msm_ext_disp_audio_codec_rx_dai_shutdown(
struct msm_ext_disp_codec_id codec_info;
struct msm_ext_disp_audio_codec_rx_data *codec_data =
dev_get_drvdata(dai->codec->dev);
dev_get_drvdata(dai->component->dev);
if (!codec_data || !codec_data->ext_disp_ops.teardown_done ||
!codec_data->ext_disp_ops.cable_status) {
@@ -516,7 +525,8 @@ static void msm_ext_disp_audio_codec_rx_dai_shutdown(
return;
}
dev_dbg(dai->codec->dev, "%s: DP ctl id %d Stream id %d\n", __func__,
dev_dbg(dai->component->dev, "%s: DP ctl id %d Stream id %d\n",
__func__,
codec_data->ctl[dai->id], codec_data->stream[dai->id]);
mutex_lock(&codec_data->dp_ops_lock);
@@ -534,7 +544,8 @@ static void msm_ext_disp_audio_codec_rx_dai_shutdown(
mutex_unlock(&codec_data->dp_ops_lock);
}
static int msm_ext_disp_audio_codec_rx_probe(struct snd_soc_codec *codec)
static int msm_ext_disp_audio_codec_rx_probe(
struct snd_soc_component *component)
{
struct msm_ext_disp_audio_codec_rx_data *codec_data;
struct device_node *of_node_parent = NULL;
@@ -543,14 +554,14 @@ static int msm_ext_disp_audio_codec_rx_probe(struct snd_soc_codec *codec)
GFP_KERNEL);
if (!codec_data) {
dev_err(codec->dev, "%s(): fail to allocate dai data\n",
dev_err(component->dev, "%s(): fail to allocate dai data\n",
__func__);
return -ENOMEM;
}
of_node_parent = of_get_parent(codec->dev->of_node);
of_node_parent = of_get_parent(component->dev->of_node);
if (!of_node_parent) {
dev_err(codec->dev, "%s(): Parent device tree node not found\n",
dev_err(component->dev, "%s(): Parent device tree node not found\n",
__func__);
kfree(codec_data);
return -ENODEV;
@@ -558,37 +569,39 @@ static int msm_ext_disp_audio_codec_rx_probe(struct snd_soc_codec *codec)
codec_data->ext_disp_core_pdev = of_find_device_by_node(of_node_parent);
if (!codec_data->ext_disp_core_pdev) {
dev_err(codec->dev, "%s(): can't get parent pdev\n", __func__);
dev_err(component->dev, "%s(): can't get parent pdev\n",
__func__);
kfree(codec_data);
return -ENODEV;
}
if (msm_ext_disp_register_audio_codec(codec_data->ext_disp_core_pdev,
&codec_data->ext_disp_ops)) {
dev_err(codec->dev, "%s(): can't register with ext disp core",
dev_err(component->dev, "%s(): can't register with ext disp core",
__func__);
kfree(codec_data);
return -ENODEV;
}
mutex_init(&codec_data->dp_ops_lock);
dev_set_drvdata(codec->dev, codec_data);
dev_set_drvdata(component->dev, codec_data);
dev_dbg(codec->dev, "%s(): registered %s with ext disp core\n",
__func__, codec->component.name);
dev_dbg(component->dev, "%s(): registered %s with ext disp core\n",
__func__, component->name);
return 0;
}
static int msm_ext_disp_audio_codec_rx_remove(struct snd_soc_codec *codec)
static void msm_ext_disp_audio_codec_rx_remove(
struct snd_soc_component *component)
{
struct msm_ext_disp_audio_codec_rx_data *codec_data;
codec_data = dev_get_drvdata(codec->dev);
codec_data = dev_get_drvdata(component->dev);
mutex_destroy(&codec_data->dp_ops_lock);
kfree(codec_data);
return 0;
return;
}
static struct snd_soc_dai_ops msm_ext_disp_audio_codec_rx_dai_ops = {
@@ -648,13 +661,12 @@ static struct snd_soc_dai_driver msm_ext_disp_audio_codec_rx_dais[] = {
},
};
static struct snd_soc_codec_driver msm_ext_disp_audio_codec_rx_soc_driver = {
static const struct snd_soc_component_driver msm_ext_disp_codec_rx_driver = {
.name = DRV_NAME,
.probe = msm_ext_disp_audio_codec_rx_probe,
.remove = msm_ext_disp_audio_codec_rx_remove,
.component_driver = {
.controls = msm_ext_disp_codec_rx_controls,
.num_controls = ARRAY_SIZE(msm_ext_disp_codec_rx_controls),
},
.controls = msm_ext_disp_codec_rx_controls,
.num_controls = ARRAY_SIZE(msm_ext_disp_codec_rx_controls),
};
static int msm_ext_disp_audio_codec_rx_plat_probe(
@@ -663,8 +675,8 @@ static int msm_ext_disp_audio_codec_rx_plat_probe(
dev_dbg(&pdev->dev, "%s(): dev name %s\n", __func__,
dev_name(&pdev->dev));
return snd_soc_register_codec(&pdev->dev,
&msm_ext_disp_audio_codec_rx_soc_driver,
return snd_soc_register_component(&pdev->dev,
&msm_ext_disp_codec_rx_driver,
msm_ext_disp_audio_codec_rx_dais,
ARRAY_SIZE(msm_ext_disp_audio_codec_rx_dais));
}
@@ -672,7 +684,7 @@ static int msm_ext_disp_audio_codec_rx_plat_probe(
static int msm_ext_disp_audio_codec_rx_plat_remove(
struct platform_device *pdev)
{
snd_soc_unregister_codec(&pdev->dev);
snd_soc_unregister_component(&pdev->dev);
return 0;
}
static const struct of_device_id msm_ext_disp_audio_codec_rx_dt_match[] = {