Skip to content

Commit f3eef3c

Browse files
lyakhlgirdwood
authored andcommitted
Fix IMR type parsing
The IMR type can be specified either in the TOML configuration file or on the command line. The command line value should override the one from the configuration file. But the current code overwrites the configuration file value with the default value even if no value has been specified on the command line, which is wrong. Fix this by using the default value when reading the configuration file and only overwriting it when the respective command line parameter is used. Signed-off-by: Guennadi Liakhovetski <guennadi.liakhovetski@linux.intel.com>
1 parent bdba825 commit f3eef3c

2 files changed

Lines changed: 12 additions & 5 deletions

File tree

src/adsp_config.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1579,7 +1579,8 @@ static int parse_adsp_file_ext_v1_8(const toml_table_t *toml, struct parse_ctx *
15791579
out->ext_len = sizeof(struct sof_man_adsp_meta_file_ext_v1_8);
15801580

15811581
/* configurable fields */
1582-
out->imr_type = parse_uint32_hex_key(adsp_file_ext, &ctx, "imr_type", 0, &ret);
1582+
out->imr_type = parse_uint32_hex_key(adsp_file_ext, &ctx, "imr_type",
1583+
MAN_DEFAULT_IMR_TYPE, &ret);
15831584
if (ret < 0)
15841585
return ret;
15851586

@@ -1699,7 +1700,8 @@ static int parse_adsp_file_ext_v2_5(const toml_table_t *toml, struct parse_ctx *
16991700
out->ext_len = sizeof(struct sof_man_adsp_meta_file_ext_v2_5);
17001701

17011702
/* configurable fields */
1702-
out->imr_type = parse_uint32_hex_key(adsp_file_ext, &ctx, "imr_type", 0, &ret);
1703+
out->imr_type = parse_uint32_hex_key(adsp_file_ext, &ctx, "imr_type",
1704+
MAN_DEFAULT_IMR_TYPE, &ret);
17031705
if (ret < 0)
17041706
return ret;
17051707

src/rimage.c

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ int main(int argc, char *argv[])
4343
int imr_type = MAN_DEFAULT_IMR_TYPE;
4444
int use_ext_man = 0;
4545
unsigned int pv_bit = 0;
46+
bool imr_type_override = false;
4647

4748
memset(&image, 0, sizeof(image));
4849

@@ -68,6 +69,7 @@ int main(int argc, char *argv[])
6869
break;
6970
case 'i':
7071
imr_type = atoi(optarg);
72+
imr_type_override = true;
7173
break;
7274
case 'f':
7375
image.fw_ver_string = optarg;
@@ -170,17 +172,20 @@ int main(int argc, char *argv[])
170172

171173
/* set IMR Type and the PV bit in found machine definition */
172174
if (image.adsp->man_v1_8) {
173-
image.adsp->man_v1_8->adsp_file_ext.imr_type = imr_type;
175+
if (imr_type_override)
176+
image.adsp->man_v1_8->adsp_file_ext.imr_type = imr_type;
174177
image.adsp->man_v1_8->css.reserved0 = pv_bit;
175178
}
176179

177180
if (image.adsp->man_v2_5) {
178-
image.adsp->man_v2_5->adsp_file_ext.imr_type = imr_type;
181+
if (imr_type_override)
182+
image.adsp->man_v2_5->adsp_file_ext.imr_type = imr_type;
179183
image.adsp->man_v2_5->css.reserved0 = pv_bit;
180184
}
181185

182186
if (image.adsp->man_ace_v1_5) {
183-
image.adsp->man_ace_v1_5->adsp_file_ext.imr_type = imr_type;
187+
if (imr_type_override)
188+
image.adsp->man_ace_v1_5->adsp_file_ext.imr_type = imr_type;
184189
image.adsp->man_ace_v1_5->css.reserved0 = pv_bit;
185190
}
186191

0 commit comments

Comments
 (0)