diff options
-rw-r--r-- | sound/soc/codecs/wm_adsp.c | 134 |
1 files changed, 64 insertions, 70 deletions
diff --git a/sound/soc/codecs/wm_adsp.c b/sound/soc/codecs/wm_adsp.c index 37e01b0b93f6..9283d08de3d9 100644 --- a/sound/soc/codecs/wm_adsp.c +++ b/sound/soc/codecs/wm_adsp.c | |||
@@ -913,6 +913,25 @@ static void *wm_adsp_read_algs(struct wm_adsp *dsp, size_t n_algs, | |||
913 | return alg; | 913 | return alg; |
914 | } | 914 | } |
915 | 915 | ||
916 | static struct wm_adsp_alg_region *wm_adsp_create_region(struct wm_adsp *dsp, | ||
917 | int type, __be32 id, | ||
918 | __be32 base) | ||
919 | { | ||
920 | struct wm_adsp_alg_region *alg_region; | ||
921 | |||
922 | alg_region = kzalloc(sizeof(*alg_region), GFP_KERNEL); | ||
923 | if (!alg_region) | ||
924 | return ERR_PTR(-ENOMEM); | ||
925 | |||
926 | alg_region->type = type; | ||
927 | alg_region->alg = be32_to_cpu(id); | ||
928 | alg_region->base = be32_to_cpu(base); | ||
929 | |||
930 | list_add_tail(&alg_region->list, &dsp->alg_regions); | ||
931 | |||
932 | return alg_region; | ||
933 | } | ||
934 | |||
916 | static int wm_adsp1_setup_algs(struct wm_adsp *dsp) | 935 | static int wm_adsp1_setup_algs(struct wm_adsp *dsp) |
917 | { | 936 | { |
918 | struct wmfw_adsp1_id_hdr adsp1_id; | 937 | struct wmfw_adsp1_id_hdr adsp1_id; |
@@ -944,21 +963,15 @@ static int wm_adsp1_setup_algs(struct wm_adsp *dsp) | |||
944 | be32_to_cpu(adsp1_id.fw.ver) & 0xff, | 963 | be32_to_cpu(adsp1_id.fw.ver) & 0xff, |
945 | n_algs); | 964 | n_algs); |
946 | 965 | ||
947 | alg_region = kzalloc(sizeof(*alg_region), GFP_KERNEL); | 966 | alg_region = wm_adsp_create_region(dsp, WMFW_ADSP1_ZM, |
948 | if (!alg_region) | 967 | adsp1_id.fw.id, adsp1_id.zm); |
949 | return -ENOMEM; | 968 | if (IS_ERR(alg_region)) |
950 | alg_region->type = WMFW_ADSP1_ZM; | 969 | return PTR_ERR(alg_region); |
951 | alg_region->alg = be32_to_cpu(adsp1_id.fw.id); | ||
952 | alg_region->base = be32_to_cpu(adsp1_id.zm); | ||
953 | list_add_tail(&alg_region->list, &dsp->alg_regions); | ||
954 | 970 | ||
955 | alg_region = kzalloc(sizeof(*alg_region), GFP_KERNEL); | 971 | alg_region = wm_adsp_create_region(dsp, WMFW_ADSP1_DM, |
956 | if (!alg_region) | 972 | adsp1_id.fw.id, adsp1_id.dm); |
957 | return -ENOMEM; | 973 | if (IS_ERR(alg_region)) |
958 | alg_region->type = WMFW_ADSP1_DM; | 974 | return PTR_ERR(alg_region); |
959 | alg_region->alg = be32_to_cpu(adsp1_id.fw.id); | ||
960 | alg_region->base = be32_to_cpu(adsp1_id.dm); | ||
961 | list_add_tail(&alg_region->list, &dsp->alg_regions); | ||
962 | 975 | ||
963 | pos = sizeof(adsp1_id) / 2; | 976 | pos = sizeof(adsp1_id) / 2; |
964 | len = (sizeof(*adsp1_alg) * n_algs) / 2; | 977 | len = (sizeof(*adsp1_alg) * n_algs) / 2; |
@@ -976,15 +989,13 @@ static int wm_adsp1_setup_algs(struct wm_adsp *dsp) | |||
976 | be32_to_cpu(adsp1_alg[i].dm), | 989 | be32_to_cpu(adsp1_alg[i].dm), |
977 | be32_to_cpu(adsp1_alg[i].zm)); | 990 | be32_to_cpu(adsp1_alg[i].zm)); |
978 | 991 | ||
979 | alg_region = kzalloc(sizeof(*alg_region), GFP_KERNEL); | 992 | alg_region = wm_adsp_create_region(dsp, WMFW_ADSP1_DM, |
980 | if (!alg_region) { | 993 | adsp1_alg[i].alg.id, |
981 | ret = -ENOMEM; | 994 | adsp1_alg[i].dm); |
995 | if (IS_ERR(alg_region)) { | ||
996 | ret = PTR_ERR(alg_region); | ||
982 | goto out; | 997 | goto out; |
983 | } | 998 | } |
984 | alg_region->type = WMFW_ADSP1_DM; | ||
985 | alg_region->alg = be32_to_cpu(adsp1_alg[i].alg.id); | ||
986 | alg_region->base = be32_to_cpu(adsp1_alg[i].dm); | ||
987 | list_add_tail(&alg_region->list, &dsp->alg_regions); | ||
988 | if (i + 1 < n_algs) { | 999 | if (i + 1 < n_algs) { |
989 | len = be32_to_cpu(adsp1_alg[i + 1].dm); | 1000 | len = be32_to_cpu(adsp1_alg[i + 1].dm); |
990 | len -= be32_to_cpu(adsp1_alg[i].dm); | 1001 | len -= be32_to_cpu(adsp1_alg[i].dm); |
@@ -995,15 +1006,13 @@ static int wm_adsp1_setup_algs(struct wm_adsp *dsp) | |||
995 | be32_to_cpu(adsp1_alg[i].alg.id)); | 1006 | be32_to_cpu(adsp1_alg[i].alg.id)); |
996 | } | 1007 | } |
997 | 1008 | ||
998 | alg_region = kzalloc(sizeof(*alg_region), GFP_KERNEL); | 1009 | alg_region = wm_adsp_create_region(dsp, WMFW_ADSP1_ZM, |
999 | if (!alg_region) { | 1010 | adsp1_alg[i].alg.id, |
1000 | ret = -ENOMEM; | 1011 | adsp1_alg[i].zm); |
1012 | if (IS_ERR(alg_region)) { | ||
1013 | ret = PTR_ERR(alg_region); | ||
1001 | goto out; | 1014 | goto out; |
1002 | } | 1015 | } |
1003 | alg_region->type = WMFW_ADSP1_ZM; | ||
1004 | alg_region->alg = be32_to_cpu(adsp1_alg[i].alg.id); | ||
1005 | alg_region->base = be32_to_cpu(adsp1_alg[i].zm); | ||
1006 | list_add_tail(&alg_region->list, &dsp->alg_regions); | ||
1007 | if (i + 1 < n_algs) { | 1016 | if (i + 1 < n_algs) { |
1008 | len = be32_to_cpu(adsp1_alg[i + 1].zm); | 1017 | len = be32_to_cpu(adsp1_alg[i + 1].zm); |
1009 | len -= be32_to_cpu(adsp1_alg[i].zm); | 1018 | len -= be32_to_cpu(adsp1_alg[i].zm); |
@@ -1051,29 +1060,20 @@ static int wm_adsp2_setup_algs(struct wm_adsp *dsp) | |||
1051 | be32_to_cpu(adsp2_id.fw.ver) & 0xff, | 1060 | be32_to_cpu(adsp2_id.fw.ver) & 0xff, |
1052 | n_algs); | 1061 | n_algs); |
1053 | 1062 | ||
1054 | alg_region = kzalloc(sizeof(*alg_region), GFP_KERNEL); | 1063 | alg_region = wm_adsp_create_region(dsp, WMFW_ADSP2_XM, |
1055 | if (!alg_region) | 1064 | adsp2_id.fw.id, adsp2_id.xm); |
1056 | return -ENOMEM; | 1065 | if (IS_ERR(alg_region)) |
1057 | alg_region->type = WMFW_ADSP2_XM; | 1066 | return PTR_ERR(alg_region); |
1058 | alg_region->alg = be32_to_cpu(adsp2_id.fw.id); | ||
1059 | alg_region->base = be32_to_cpu(adsp2_id.xm); | ||
1060 | list_add_tail(&alg_region->list, &dsp->alg_regions); | ||
1061 | 1067 | ||
1062 | alg_region = kzalloc(sizeof(*alg_region), GFP_KERNEL); | 1068 | alg_region = wm_adsp_create_region(dsp, WMFW_ADSP2_YM, |
1063 | if (!alg_region) | 1069 | adsp2_id.fw.id, adsp2_id.ym); |
1064 | return -ENOMEM; | 1070 | if (IS_ERR(alg_region)) |
1065 | alg_region->type = WMFW_ADSP2_YM; | 1071 | return PTR_ERR(alg_region); |
1066 | alg_region->alg = be32_to_cpu(adsp2_id.fw.id); | ||
1067 | alg_region->base = be32_to_cpu(adsp2_id.ym); | ||
1068 | list_add_tail(&alg_region->list, &dsp->alg_regions); | ||
1069 | 1072 | ||
1070 | alg_region = kzalloc(sizeof(*alg_region), GFP_KERNEL); | 1073 | alg_region = wm_adsp_create_region(dsp, WMFW_ADSP2_ZM, |
1071 | if (!alg_region) | 1074 | adsp2_id.fw.id, adsp2_id.zm); |
1072 | return -ENOMEM; | 1075 | if (IS_ERR(alg_region)) |
1073 | alg_region->type = WMFW_ADSP2_ZM; | 1076 | return PTR_ERR(alg_region); |
1074 | alg_region->alg = be32_to_cpu(adsp2_id.fw.id); | ||
1075 | alg_region->base = be32_to_cpu(adsp2_id.zm); | ||
1076 | list_add_tail(&alg_region->list, &dsp->alg_regions); | ||
1077 | 1077 | ||
1078 | pos = sizeof(adsp2_id) / 2; | 1078 | pos = sizeof(adsp2_id) / 2; |
1079 | len = (sizeof(*adsp2_alg) * n_algs) / 2; | 1079 | len = (sizeof(*adsp2_alg) * n_algs) / 2; |
@@ -1093,15 +1093,13 @@ static int wm_adsp2_setup_algs(struct wm_adsp *dsp) | |||
1093 | be32_to_cpu(adsp2_alg[i].ym), | 1093 | be32_to_cpu(adsp2_alg[i].ym), |
1094 | be32_to_cpu(adsp2_alg[i].zm)); | 1094 | be32_to_cpu(adsp2_alg[i].zm)); |
1095 | 1095 | ||
1096 | alg_region = kzalloc(sizeof(*alg_region), GFP_KERNEL); | 1096 | alg_region = wm_adsp_create_region(dsp, WMFW_ADSP2_XM, |
1097 | if (!alg_region) { | 1097 | adsp2_alg[i].alg.id, |
1098 | ret = -ENOMEM; | 1098 | adsp2_alg[i].xm); |
1099 | if (IS_ERR(alg_region)) { | ||
1100 | ret = PTR_ERR(alg_region); | ||
1099 | goto out; | 1101 | goto out; |
1100 | } | 1102 | } |
1101 | alg_region->type = WMFW_ADSP2_XM; | ||
1102 | alg_region->alg = be32_to_cpu(adsp2_alg[i].alg.id); | ||
1103 | alg_region->base = be32_to_cpu(adsp2_alg[i].xm); | ||
1104 | list_add_tail(&alg_region->list, &dsp->alg_regions); | ||
1105 | if (i + 1 < n_algs) { | 1103 | if (i + 1 < n_algs) { |
1106 | len = be32_to_cpu(adsp2_alg[i + 1].xm); | 1104 | len = be32_to_cpu(adsp2_alg[i + 1].xm); |
1107 | len -= be32_to_cpu(adsp2_alg[i].xm); | 1105 | len -= be32_to_cpu(adsp2_alg[i].xm); |
@@ -1112,15 +1110,13 @@ static int wm_adsp2_setup_algs(struct wm_adsp *dsp) | |||
1112 | be32_to_cpu(adsp2_alg[i].alg.id)); | 1110 | be32_to_cpu(adsp2_alg[i].alg.id)); |
1113 | } | 1111 | } |
1114 | 1112 | ||
1115 | alg_region = kzalloc(sizeof(*alg_region), GFP_KERNEL); | 1113 | alg_region = wm_adsp_create_region(dsp, WMFW_ADSP2_YM, |
1116 | if (!alg_region) { | 1114 | adsp2_alg[i].alg.id, |
1117 | ret = -ENOMEM; | 1115 | adsp2_alg[i].ym); |
1116 | if (IS_ERR(alg_region)) { | ||
1117 | ret = PTR_ERR(alg_region); | ||
1118 | goto out; | 1118 | goto out; |
1119 | } | 1119 | } |
1120 | alg_region->type = WMFW_ADSP2_YM; | ||
1121 | alg_region->alg = be32_to_cpu(adsp2_alg[i].alg.id); | ||
1122 | alg_region->base = be32_to_cpu(adsp2_alg[i].ym); | ||
1123 | list_add_tail(&alg_region->list, &dsp->alg_regions); | ||
1124 | if (i + 1 < n_algs) { | 1120 | if (i + 1 < n_algs) { |
1125 | len = be32_to_cpu(adsp2_alg[i + 1].ym); | 1121 | len = be32_to_cpu(adsp2_alg[i + 1].ym); |
1126 | len -= be32_to_cpu(adsp2_alg[i].ym); | 1122 | len -= be32_to_cpu(adsp2_alg[i].ym); |
@@ -1131,15 +1127,13 @@ static int wm_adsp2_setup_algs(struct wm_adsp *dsp) | |||
1131 | be32_to_cpu(adsp2_alg[i].alg.id)); | 1127 | be32_to_cpu(adsp2_alg[i].alg.id)); |
1132 | } | 1128 | } |
1133 | 1129 | ||
1134 | alg_region = kzalloc(sizeof(*alg_region), GFP_KERNEL); | 1130 | alg_region = wm_adsp_create_region(dsp, WMFW_ADSP2_ZM, |
1135 | if (!alg_region) { | 1131 | adsp2_alg[i].alg.id, |
1136 | ret = -ENOMEM; | 1132 | adsp2_alg[i].zm); |
1133 | if (IS_ERR(alg_region)) { | ||
1134 | ret = PTR_ERR(alg_region); | ||
1137 | goto out; | 1135 | goto out; |
1138 | } | 1136 | } |
1139 | alg_region->type = WMFW_ADSP2_ZM; | ||
1140 | alg_region->alg = be32_to_cpu(adsp2_alg[i].alg.id); | ||
1141 | alg_region->base = be32_to_cpu(adsp2_alg[i].zm); | ||
1142 | list_add_tail(&alg_region->list, &dsp->alg_regions); | ||
1143 | if (i + 1 < n_algs) { | 1137 | if (i + 1 < n_algs) { |
1144 | len = be32_to_cpu(adsp2_alg[i + 1].zm); | 1138 | len = be32_to_cpu(adsp2_alg[i + 1].zm); |
1145 | len -= be32_to_cpu(adsp2_alg[i].zm); | 1139 | len -= be32_to_cpu(adsp2_alg[i].zm); |