@@ -109,9 +109,11 @@ For a function using multiple GPIOs all of those can be obtained with one call::
109109 enum gpiod_flags flags)
110110
111111This function returns a struct gpio_descs which contains an array of
112- descriptors::
112+ descriptors. It also contains a pointer to a gpiolib private structure which,
113+ if passed back to get/set array functions, may speed up I/O proocessing::
113114
114115 struct gpio_descs {
116+ struct gpio_array *info;
115117 unsigned int ndescs;
116118 struct gpio_desc *desc[];
117119 }
@@ -323,29 +325,37 @@ The following functions get or set the values of an array of GPIOs::
323325
324326 int gpiod_get_array_value(unsigned int array_size,
325327 struct gpio_desc **desc_array,
326- int *value_array);
328+ struct gpio_array *array_info,
329+ unsigned long *value_bitmap);
327330 int gpiod_get_raw_array_value(unsigned int array_size,
328331 struct gpio_desc **desc_array,
329- int *value_array);
332+ struct gpio_array *array_info,
333+ unsigned long *value_bitmap);
330334 int gpiod_get_array_value_cansleep(unsigned int array_size,
331335 struct gpio_desc **desc_array,
332- int *value_array);
336+ struct gpio_array *array_info,
337+ unsigned long *value_bitmap);
333338 int gpiod_get_raw_array_value_cansleep(unsigned int array_size,
334339 struct gpio_desc **desc_array,
335- int *value_array);
340+ struct gpio_array *array_info,
341+ unsigned long *value_bitmap);
336342
337343 void gpiod_set_array_value(unsigned int array_size,
338344 struct gpio_desc **desc_array,
339- int *value_array)
345+ struct gpio_array *array_info,
346+ unsigned long *value_bitmap)
340347 void gpiod_set_raw_array_value(unsigned int array_size,
341348 struct gpio_desc **desc_array,
342- int *value_array)
349+ struct gpio_array *array_info,
350+ unsigned long *value_bitmap)
343351 void gpiod_set_array_value_cansleep(unsigned int array_size,
344352 struct gpio_desc **desc_array,
345- int *value_array)
353+ struct gpio_array *array_info,
354+ unsigned long *value_bitmap)
346355 void gpiod_set_raw_array_value_cansleep(unsigned int array_size,
347356 struct gpio_desc **desc_array,
348- int *value_array)
357+ struct gpio_array *array_info,
358+ unsigned long *value_bitmap)
349359
350360The array can be an arbitrary set of GPIOs. The functions will try to access
351361GPIOs belonging to the same bank or chip simultaneously if supported by the
@@ -356,8 +366,9 @@ accessed sequentially.
356366The functions take three arguments:
357367 * array_size - the number of array elements
358368 * desc_array - an array of GPIO descriptors
359- * value_array - an array to store the GPIOs' values (get) or
360- an array of values to assign to the GPIOs (set)
369+ * array_info - optional information obtained from gpiod_array_get()
370+ * value_bitmap - a bitmap to store the GPIOs' values (get) or
371+ a bitmap of values to assign to the GPIOs (set)
361372
362373The descriptor array can be obtained using the gpiod_get_array() function
363374or one of its variants. If the group of descriptors returned by that function
@@ -366,16 +377,25 @@ the struct gpio_descs returned by gpiod_get_array()::
366377
367378 struct gpio_descs *my_gpio_descs = gpiod_get_array(...);
368379 gpiod_set_array_value(my_gpio_descs->ndescs, my_gpio_descs->desc,
369- my_gpio_values );
380+ my_gpio_descs->info, my_gpio_value_bitmap );
370381
371382It is also possible to access a completely arbitrary array of descriptors. The
372383descriptors may be obtained using any combination of gpiod_get() and
373384gpiod_get_array(). Afterwards the array of descriptors has to be setup
374- manually before it can be passed to one of the above functions.
385+ manually before it can be passed to one of the above functions. In that case,
386+ array_info should be set to NULL.
375387
376388Note that for optimal performance GPIOs belonging to the same chip should be
377389contiguous within the array of descriptors.
378390
391+ Still better performance may be achieved if array indexes of the descriptors
392+ match hardware pin numbers of a single chip. If an array passed to a get/set
393+ array function matches the one obtained from gpiod_get_array() and array_info
394+ associated with the array is also passed, the function may take a fast bitmap
395+ processing path, passing the value_bitmap argument directly to the respective
396+ .get/set_multiple() callback of the chip. That allows for utilization of GPIO
397+ banks as data I/O ports without much loss of performance.
398+
379399The return value of gpiod_get_array_value() and its variants is 0 on success
380400or negative on error. Note the difference to gpiod_get_value(), which returns
3814010 or 1 on success to convey the GPIO value. With the array functions, the GPIO
0 commit comments