+static int make_column_details_single(struct context *inc,
+ size_t col_nr, size_t bit_count, enum single_col_format format)
+{
+ struct column_details *details;
+
+ /*
+ * Need at least as many columns to also include the one with
+ * the single-column input data.
+ */
+ inc->column_want_count = col_nr;
+
+ /*
+ * Allocate the columns' processing details. Columns are counted
+ * from 1 (user's perspective), array items from 0 (programmer's
+ * perspective).
+ */
+ inc->column_details = g_malloc0_n(col_nr, sizeof(inc->column_details[0]));
+ details = &inc->column_details[col_nr - 1];
+ details->col_nr = col_nr;
+
+ /*
+ * In single-column mode this single column will hold all bits
+ * of all logic channels, in the user specified number format.
+ */
+ details->text_format = format;
+ details->channel_offset = 0;
+ details->channel_count = bit_count;
+
+ return SR_OK;
+}
+
+static int make_column_details_multi(struct context *inc,
+ size_t first_col, size_t last_col)
+{
+ struct column_details *details;
+ size_t col_nr;
+
+ /*
+ * Need at least as many columns to also include the one with
+ * the last channel's data.
+ */
+ inc->column_want_count = last_col;
+
+ /*
+ * Allocate the columns' processing details. Columns are counted
+ * from 1, array items from 0.
+ * In multi-column mode each column will hold a single bit for
+ * the respective channel.
+ */
+ inc->column_details = g_malloc0_n(last_col, sizeof(inc->column_details[0]));
+ for (col_nr = first_col; col_nr <= last_col; col_nr++) {
+ details = &inc->column_details[col_nr - 1];
+ details->col_nr = col_nr;
+ details->text_format = FORMAT_BIN;
+ details->channel_offset = col_nr - first_col;
+ details->channel_count = 1;
+ }
+
+
+ return SR_OK;
+}
+
+static const struct column_details *lookup_column_details(struct context *inc, size_t nr)
+{
+ if (!inc || !inc->column_details)
+ return NULL;
+ if (!nr || nr > inc->column_want_count)
+ return NULL;
+ return &inc->column_details[nr - 1];
+}
+