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

Configure Feed

Select the types of activity you want to include in your feed.

ASoC: SDCA: add support for HIDE entity properties and HID descriptor/report

Add support for parsing the HIDE entity descriptor and HID descriptor/report

Signed-off-by: Shuming Fan <shumingf@realtek.com>
Reviewed-by: Charles Keepax <ckeepax@opensource.cirrus.com>
Link: https://patch.msgid.link/20250616114820.855401-1-shumingf@realtek.com
Signed-off-by: Mark Brown <broonie@kernel.org>

authored by

Shuming Fan and committed by
Mark Brown
13ef21df f186a1a9

+112
+29
include/sound/sdca_function.h
··· 11 11 12 12 #include <linux/bits.h> 13 13 #include <linux/types.h> 14 + #include <linux/hid.h> 14 15 15 16 struct device; 16 17 struct sdca_entity; ··· 1042 1041 }; 1043 1042 1044 1043 /** 1044 + * struct sdca_entity_hide - information specific to HIDE Entities 1045 + * @hid: HID device structure 1046 + * @hidtx_ids: HIDTx Report ID 1047 + * @num_hidtx_ids: number of HIDTx Report ID 1048 + * @hidrx_ids: HIDRx Report ID 1049 + * @num_hidrx_ids: number of HIDRx Report ID 1050 + * @hide_reside_function_num: indicating which Audio Function Numbers within this Device 1051 + * @max_delay: the maximum time in microseconds allowed for the Device to change the ownership from Device to Host 1052 + * @af_number_list: which Audio Function Numbers within this Device are sending/receiving the messages in this HIDE 1053 + * @hid_desc: HID descriptor for the HIDE Entity 1054 + * @hid_report_desc: HID Report Descriptor for the HIDE Entity 1055 + */ 1056 + struct sdca_entity_hide { 1057 + struct hid_device *hid; 1058 + unsigned int *hidtx_ids; 1059 + int num_hidtx_ids; 1060 + unsigned int *hidrx_ids; 1061 + int num_hidrx_ids; 1062 + unsigned int hide_reside_function_num; 1063 + unsigned int max_delay; 1064 + unsigned int af_number_list[SDCA_MAX_FUNCTION_COUNT]; 1065 + struct hid_descriptor hid_desc; 1066 + unsigned char *hid_report_desc; 1067 + }; 1068 + 1069 + /** 1045 1070 * struct sdca_entity - information for one SDCA Entity 1046 1071 * @label: String such as "OT 12". 1047 1072 * @id: Identifier used for addressing. ··· 1082 1055 * @cs: Clock Source specific Entity properties. 1083 1056 * @pde: Power Domain Entity specific Entity properties. 1084 1057 * @ge: Group Entity specific Entity properties. 1058 + * @hide: HIDE Entity specific Entity properties. 1085 1059 */ 1086 1060 struct sdca_entity { 1087 1061 const char *label; ··· 1099 1071 struct sdca_entity_cs cs; 1100 1072 struct sdca_entity_pde pde; 1101 1073 struct sdca_entity_ge ge; 1074 + struct sdca_entity_hide hide; 1102 1075 }; 1103 1076 }; 1104 1077
+83
sound/soc/sdca/sdca_functions.c
··· 1220 1220 return -EINVAL; 1221 1221 } 1222 1222 1223 + static int 1224 + find_sdca_entity_hide(struct device *dev, struct fwnode_handle *function_node, 1225 + struct fwnode_handle *entity_node, struct sdca_entity *entity) 1226 + { 1227 + struct sdca_entity_hide *hide = &entity->hide; 1228 + unsigned int delay, *af_list = hide->af_number_list; 1229 + int nval, ret; 1230 + unsigned char *report_desc = NULL; 1231 + 1232 + ret = fwnode_property_read_u32(entity_node, 1233 + "mipi-sdca-RxUMP-ownership-transition-maxdelay", &delay); 1234 + if (!ret) 1235 + hide->max_delay = delay; 1236 + 1237 + nval = fwnode_property_count_u32(entity_node, "mipi-sdca-HIDTx-supported-report-ids"); 1238 + if (nval > 0) { 1239 + hide->num_hidtx_ids = nval; 1240 + hide->hidtx_ids = devm_kcalloc(dev, hide->num_hidtx_ids, 1241 + sizeof(*hide->hidtx_ids), GFP_KERNEL); 1242 + if (!hide->hidtx_ids) 1243 + return -ENOMEM; 1244 + 1245 + ret = fwnode_property_read_u32_array(entity_node, 1246 + "mipi-sdca-HIDTx-supported-report-ids", 1247 + hide->hidtx_ids, 1248 + hide->num_hidtx_ids); 1249 + if (ret < 0) 1250 + return ret; 1251 + } 1252 + 1253 + nval = fwnode_property_count_u32(entity_node, "mipi-sdca-HIDRx-supported-report-ids"); 1254 + if (nval > 0) { 1255 + hide->num_hidrx_ids = nval; 1256 + hide->hidrx_ids = devm_kcalloc(dev, hide->num_hidrx_ids, 1257 + sizeof(*hide->hidrx_ids), GFP_KERNEL); 1258 + if (!hide->hidrx_ids) 1259 + return -ENOMEM; 1260 + 1261 + ret = fwnode_property_read_u32_array(entity_node, 1262 + "mipi-sdca-HIDRx-supported-report-ids", 1263 + hide->hidrx_ids, 1264 + hide->num_hidrx_ids); 1265 + if (ret < 0) 1266 + return ret; 1267 + } 1268 + 1269 + nval = fwnode_property_count_u32(entity_node, "mipi-sdca-hide-related-audio-function-list"); 1270 + if (nval <= 0) { 1271 + dev_err(dev, "%pfwP: audio function numbers list missing: %d\n", 1272 + entity_node, nval); 1273 + return -EINVAL; 1274 + } else if (nval > SDCA_MAX_FUNCTION_COUNT) { 1275 + dev_err(dev, "%pfwP: maximum number of audio function exceeded\n", entity_node); 1276 + return -EINVAL; 1277 + } 1278 + 1279 + hide->hide_reside_function_num = nval; 1280 + fwnode_property_read_u32_array(entity_node, 1281 + "mipi-sdca-hide-related-audio-function-list", af_list, nval); 1282 + 1283 + nval = fwnode_property_count_u8(function_node, "mipi-sdca-hid-descriptor"); 1284 + if (nval) 1285 + fwnode_property_read_u8_array(function_node, "mipi-sdca-hid-descriptor", 1286 + (u8 *)&hide->hid_desc, nval); 1287 + 1288 + if (hide->hid_desc.bNumDescriptors) { 1289 + nval = fwnode_property_count_u8(function_node, "mipi-sdca-report-descriptor"); 1290 + if (nval) { 1291 + report_desc = devm_kzalloc(dev, nval, GFP_KERNEL); 1292 + if (!report_desc) 1293 + return -ENOMEM; 1294 + hide->hid_report_desc = report_desc; 1295 + fwnode_property_read_u8_array(function_node, "mipi-sdca-report-descriptor", 1296 + report_desc, nval); 1297 + } 1298 + } 1299 + 1300 + return 0; 1301 + } 1302 + 1223 1303 static int find_sdca_entity(struct device *dev, 1224 1304 struct fwnode_handle *function_node, 1225 1305 struct fwnode_handle *entity_node, ··· 1340 1260 break; 1341 1261 case SDCA_ENTITY_TYPE_GE: 1342 1262 ret = find_sdca_entity_ge(dev, entity_node, entity); 1263 + break; 1264 + case SDCA_ENTITY_TYPE_HIDE: 1265 + ret = find_sdca_entity_hide(dev, function_node, entity_node, entity); 1343 1266 break; 1344 1267 default: 1345 1268 break;