@@ -1222,6 +1222,95 @@ static int find_sdca_entity_ge(struct device *dev,
12221222 return - EINVAL ;
12231223}
12241224
1225+ static int
1226+ find_sdca_entity_hide (struct device * dev , struct fwnode_handle * function_node ,
1227+ struct fwnode_handle * entity_node ,
1228+ struct sdca_entity * entity )
1229+ {
1230+ struct sdca_entity_hide * hide = & entity -> hide ;
1231+ struct hid_descriptor hid_desc ;
1232+ unsigned int delay , af_list [SDCA_MAX_FUNCTION_COUNT ];
1233+ int nval , ret ;
1234+ unsigned char * report_desc = NULL ;
1235+
1236+ ret = fwnode_property_read_u32 (entity_node ,
1237+ "mipi-sdca-RxUMP-ownership-transition-maxdelay" , & delay );
1238+ if (!ret )
1239+ hide -> max_delay = delay ;
1240+
1241+ nval = fwnode_property_count_u32 (entity_node , "mipi-sdca-HIDTx-supported-report-ids" );
1242+ if (nval > 0 ) {
1243+ hide -> num_hidtx_ids = nval ;
1244+ hide -> hidtx_ids = devm_kcalloc (dev , hide -> num_hidtx_ids ,
1245+ sizeof (* hide -> hidtx_ids ), GFP_KERNEL );
1246+ if (!hide -> hidtx_ids )
1247+ return - ENOMEM ;
1248+
1249+ ret = fwnode_property_read_u32_array (entity_node ,
1250+ "mipi-sdca-HIDTx-supported-report-ids" ,
1251+ hide -> hidtx_ids ,
1252+ hide -> num_hidtx_ids );
1253+ if (ret < 0 )
1254+ return ret ;
1255+ } else {
1256+ hide -> hidtx_ids = NULL ;
1257+ }
1258+
1259+ nval = fwnode_property_count_u32 (entity_node , "mipi-sdca-HIDRx-supported-report-ids" );
1260+ if (nval > 0 ) {
1261+ hide -> num_hidtx_ids = nval ;
1262+ hide -> hidtx_ids = devm_kcalloc (dev , hide -> num_hidtx_ids ,
1263+ sizeof (* hide -> hidtx_ids ), GFP_KERNEL );
1264+ if (!hide -> hidtx_ids )
1265+ return - ENOMEM ;
1266+
1267+ ret = fwnode_property_read_u32_array (entity_node ,
1268+ "mipi-sdca-HIDRx-supported-report-ids" ,
1269+ hide -> hidtx_ids ,
1270+ hide -> num_hidtx_ids );
1271+ if (ret < 0 )
1272+ return ret ;
1273+ } else {
1274+ hide -> hidrx_ids = NULL ;
1275+ }
1276+
1277+ nval = fwnode_property_count_u32 (entity_node , "mipi-sdca-hide-related-audio-function-list" );
1278+ if (nval <= 0 ) {
1279+ dev_err (dev , "%pfwP: HIDE - audio function numbers list missing: %d\n" ,
1280+ entity_node , nval );
1281+ return - EINVAL ;
1282+ } else if (nval > SDCA_MAX_FUNCTION_COUNT ) {
1283+ dev_err (dev , "%pfwP: maximum number of audio function exceeded\n" , entity_node );
1284+ return - EINVAL ;
1285+ }
1286+
1287+ fwnode_property_read_u32_array (entity_node , "mipi-sdca-hide-related-audio-function-list" ,
1288+ & af_list [0 ], nval );
1289+
1290+ nval = fwnode_property_count_u8 (function_node , "mipi-sdca-hid-descriptor" );
1291+ if (nval )
1292+ fwnode_property_read_u8_array (function_node , "mipi-sdca-hid-descriptor" , (u8 * )& hid_desc , nval );
1293+ memcpy (& hide -> hid_desc , & hid_desc , sizeof (hid_desc ));
1294+
1295+ printk ("HIDE: num_hid_desc = %d, bLength=0x%x \
1296+ bDescriptorType=0x%x, bcdHID=0x%x, bCountryCode=0x%x bNumDescriptors=0x%x \n" ,
1297+ nval , hide -> hid_desc .bLength , hide -> hid_desc .bDescriptorType ,
1298+ hide -> hid_desc .bcdHID , hide -> hid_desc .bCountryCode , hide -> hid_desc .bNumDescriptors );
1299+
1300+ if (hid_desc .bNumDescriptors ) {
1301+ nval = fwnode_property_count_u8 (function_node , "mipi-sdca-report-descriptor" );
1302+ if (nval ) {
1303+ report_desc = devm_kzalloc (dev , nval , GFP_KERNEL );
1304+ if (!report_desc )
1305+ return - ENOMEM ;
1306+ hide -> hid_report_desc = report_desc ;
1307+ fwnode_property_read_u8_array (function_node , "mipi-sdca-report-descriptor" , report_desc , nval );
1308+ }
1309+ }
1310+
1311+ return 0 ;
1312+ }
1313+
12251314static int find_sdca_entity (struct device * dev ,
12261315 struct fwnode_handle * function_node ,
12271316 struct fwnode_handle * entity_node ,
@@ -1263,6 +1352,9 @@ static int find_sdca_entity(struct device *dev,
12631352 case SDCA_ENTITY_TYPE_GE :
12641353 ret = find_sdca_entity_ge (dev , entity_node , entity );
12651354 break ;
1355+ case SDCA_ENTITY_TYPE_HIDE :
1356+ ret = find_sdca_entity_hide (dev , function_node , entity_node , entity );
1357+ break ;
12661358 default :
12671359 break ;
12681360 }
0 commit comments