{
const char **strings;
int i;
+ unsigned int items;
__u8 *data;
- strings = devm_kzalloc(gb->dev, sizeof(char *) * gbenum->items,
- GFP_KERNEL);
+ items = le32_to_cpu(gbenum->items);
+ strings = devm_kzalloc(gb->dev, sizeof(char *) * items, GFP_KERNEL);
data = gbenum->names;
- for (i = 0; i < gbenum->items; i++) {
+ for (i = 0; i < items; i++) {
strings[i] = (const char *)data;
while (*data != '\0')
data++;
switch (info->type) {
case GB_AUDIO_CTL_ELEM_TYPE_BOOLEAN:
case GB_AUDIO_CTL_ELEM_TYPE_INTEGER:
- uinfo->value.integer.min = info->value.integer.min;
- uinfo->value.integer.max = info->value.integer.max;
+ uinfo->value.integer.min = le32_to_cpu(info->value.integer.min);
+ uinfo->value.integer.max = le32_to_cpu(info->value.integer.max);
break;
case GB_AUDIO_CTL_ELEM_TYPE_ENUMERATED:
- max = info->value.enumerated.items;
+ max = le32_to_cpu(info->value.enumerated.items);
uinfo->value.enumerated.items = max;
if (uinfo->value.enumerated.item > max - 1)
uinfo->value.enumerated.item = max - 1;
case GB_AUDIO_CTL_ELEM_TYPE_BOOLEAN:
case GB_AUDIO_CTL_ELEM_TYPE_INTEGER:
ucontrol->value.integer.value[0] =
- gbvalue.value.integer_value[0];
+ le32_to_cpu(gbvalue.value.integer_value[0]);
if (data->vcount == 2)
ucontrol->value.integer.value[1] =
- gbvalue.value.integer_value[1];
+ le32_to_cpu(gbvalue.value.integer_value[1]);
break;
case GB_AUDIO_CTL_ELEM_TYPE_ENUMERATED:
ucontrol->value.enumerated.item[0] =
- gbvalue.value.enumerated_item[0];
+ le32_to_cpu(gbvalue.value.enumerated_item[0]);
if (data->vcount == 2)
ucontrol->value.enumerated.item[1] =
- gbvalue.value.enumerated_item[1];
+ le32_to_cpu(gbvalue.value.enumerated_item[1]);
break;
default:
dev_err(codec->dev, "Invalid type: %d for %s:kcontrol\n",
case GB_AUDIO_CTL_ELEM_TYPE_BOOLEAN:
case GB_AUDIO_CTL_ELEM_TYPE_INTEGER:
gbvalue.value.integer_value[0] =
- ucontrol->value.integer.value[0];
+ cpu_to_le32(ucontrol->value.integer.value[0]);
if (data->vcount == 2)
gbvalue.value.integer_value[1] =
- ucontrol->value.integer.value[1];
+ cpu_to_le32(ucontrol->value.integer.value[1]);
break;
case GB_AUDIO_CTL_ELEM_TYPE_ENUMERATED:
gbvalue.value.enumerated_item[0] =
- ucontrol->value.enumerated.item[0];
+ cpu_to_le32(ucontrol->value.enumerated.item[0]);
if (data->vcount == 2)
gbvalue.value.enumerated_item[1] =
- ucontrol->value.enumerated.item[1];
+ cpu_to_le32(ucontrol->value.enumerated.item[1]);
break;
default:
dev_err(codec->dev, "Invalid type: %d for %s:kcontrol\n",
info = (struct gb_audio_ctl_elem_info *)data->info;
/* update uinfo */
- platform_max = info->value.integer.max;
- platform_min = info->value.integer.min;
+ platform_max = le32_to_cpu(info->value.integer.max);
+ platform_min = le32_to_cpu(info->value.integer.min);
if (platform_max == 1 &&
!strnstr(kcontrol->id.name, " Volume", NAME_SIZE))
return ret;
}
/* update ucontrol */
- ucontrol->value.integer.value[0] = gbvalue.value.integer_value[0];
+ ucontrol->value.integer.value[0] =
+ le32_to_cpu(gbvalue.value.integer_value[0]);
return ret;
}
"GB: Control '%s' is stereo, which is not supported\n",
kcontrol->id.name);
- max = info->value.integer.max;
+ max = le32_to_cpu(info->value.integer.max);
mask = (1 << fls(max)) - 1;
val = ucontrol->value.integer.value[0] & mask;
connect = !!val;
connect);
}
gbvalue.value.integer_value[0] =
- ucontrol->value.integer.value[0];
+ cpu_to_le32(ucontrol->value.integer.value[0]);
ret = gb_pm_runtime_get_sync(bundle);
if (ret)
return ret;
}
- ucontrol->value.enumerated.item[0] = gbvalue.value.enumerated_item[0];
+ ucontrol->value.enumerated.item[0] =
+ le32_to_cpu(gbvalue.value.enumerated_item[0]);
if (e->shift_l != e->shift_r)
ucontrol->value.enumerated.item[1] =
- gbvalue.value.enumerated_item[1];
+ le32_to_cpu(gbvalue.value.enumerated_item[1]);
return 0;
}
if (ucontrol->value.enumerated.item[0] > e->max - 1)
return -EINVAL;
- gbvalue.value.enumerated_item[0] = ucontrol->value.enumerated.item[0];
+ gbvalue.value.enumerated_item[0] =
+ cpu_to_le32(ucontrol->value.enumerated.item[0]);
if (e->shift_l != e->shift_r) {
if (ucontrol->value.enumerated.item[1] > e->max - 1)
return -EINVAL;
gbvalue.value.enumerated_item[1] =
- ucontrol->value.enumerated.item[1];
+ cpu_to_le32(ucontrol->value.enumerated.item[1]);
}
bundle = to_gb_bundle(module->dev);
gb_enum = &ctl->info.value.enumerated;
/* since count=1, and reg is dummy */
- gbe->max = gb_enum->items;
+ gbe->max = le32_to_cpu(gb_enum->items);
gbe->texts = gb_generate_enum_strings(gb, gb_enum);
/* debug enum info */
- dev_dbg(gb->dev, "Max:%d, name_length:%d\n", gb_enum->items,
- gb_enum->names_length);
- for (i = 0; i < gb_enum->items; i++)
+ dev_dbg(gb->dev, "Max:%d, name_length:%d\n", gbe->max,
+ le16_to_cpu(gb_enum->names_length));
+ for (i = 0; i < gbe->max; i++)
dev_dbg(gb->dev, "src[%d]: %s\n", i, gbe->texts[i]);
*kctl = (struct snd_kcontrol_new)
if (!ctldata)
return -ENOMEM;
ctldata->ctl_id = ctl->id;
- ctldata->data_cport = ctl->data_cport;
+ ctldata->data_cport = le16_to_cpu(ctl->data_cport);
ctldata->access = ctl->access;
ctldata->vcount = ctl->count_values;
ctldata->info = &ctl->info;
gb_enum = &ctl->info.value.enumerated;
/* since count=1, and reg is dummy */
- gbe->max = gb_enum->items;
+ gbe->max = le32_to_cpu(gb_enum->items);
gbe->texts = gb_generate_enum_strings(gb, gb_enum);
/* debug enum info */
- dev_dbg(gb->dev, "Max:%d, name_length:%d\n", gb_enum->items,
- gb_enum->names_length);
- for (i = 0; i < gb_enum->items; i++)
+ dev_dbg(gb->dev, "Max:%d, name_length:%d\n", gbe->max,
+ le16_to_cpu(gb_enum->names_length));
+ for (i = 0; i < gbe->max; i++)
dev_dbg(gb->dev, "src[%d]: %s\n", i, gbe->texts[i]);
*kctl = (struct snd_kcontrol_new)
if (!ctldata)
return -ENOMEM;
ctldata->ctl_id = ctl->id;
- ctldata->data_cport = ctl->data_cport;
+ ctldata->data_cport = le16_to_cpu(ctl->data_cport);
ctldata->access = ctl->access;
ctldata->vcount = ctl->count_values;
ctldata->info = &ctl->info;
csize = offsetof(struct gb_audio_control, info);
csize += offsetof(struct gb_audio_ctl_elem_info, value);
csize += offsetof(struct gb_audio_enumerated, names);
- csize += gbenum->names_length;
+ csize += le16_to_cpu(gbenum->names_length);
control->texts = (const char * const *)
gb_generate_enum_strings(module, gbenum);
- control->items = gbenum->items;
+ control->items = le32_to_cpu(gbenum->items);
} else {
csize = sizeof(struct gb_audio_control);
}
csize = offsetof(struct gb_audio_control, info);
csize += offsetof(struct gb_audio_ctl_elem_info, value);
csize += offsetof(struct gb_audio_enumerated, names);
- csize += gbenum->names_length;
+ csize += le16_to_cpu(gbenum->names_length);
control->texts = (const char * const *)
gb_generate_enum_strings(module, gbenum);
- control->items = gbenum->items;
+ control->items = le32_to_cpu(gbenum->items);
} else {
csize = sizeof(struct gb_audio_control);
}
/* update block offset */
module->dai_offset = (unsigned long)&tplg_data->data;
- module->control_offset = module->dai_offset + tplg_data->size_dais;
+ module->control_offset = module->dai_offset +
+ le32_to_cpu(tplg_data->size_dais);
module->widget_offset = module->control_offset +
- tplg_data->size_controls;
+ le32_to_cpu(tplg_data->size_controls);
module->route_offset = module->widget_offset +
- tplg_data->size_widgets;
+ le32_to_cpu(tplg_data->size_widgets);
dev_dbg(module->dev, "DAI offset is 0x%lx\n", module->dai_offset);
dev_dbg(module->dev, "control offset is %lx\n",
struct gb_audio_control *controls;
struct gb_audio_widget *widgets;
struct gb_audio_route *routes;
+ unsigned int jack_type;
if (!tplg_data)
return -EINVAL;
dev_dbg(module->dev, "Route parsing finished\n");
/* parse jack capabilities */
- if (tplg_data->jack_type) {
- module->jack_mask = tplg_data->jack_type & GBCODEC_JACK_MASK;
- module->button_mask = tplg_data->jack_type &
- GBCODEC_JACK_BUTTON_MASK;
+ jack_type = le32_to_cpu(tplg_data->jack_type);
+ if (jack_type) {
+ module->jack_mask = jack_type & GBCODEC_JACK_MASK;
+ module->button_mask = jack_type & GBCODEC_JACK_BUTTON_MASK;
}
return ret;