/* * netsniff-ng - the packet sniffing beast * Subject to the GPL, version 2. */ #include #include "ui.h" #include "str.h" #include "xmalloc.h" static struct ui_text *ui_text_alloc(size_t len) { struct ui_text *text = xzmalloc(sizeof(*text)); text->str = xzmalloc(sizeof(chtype) * len + 1); text->len = len; return text; } static void ui_text_len_set(struct ui_text *text, size_t len) { if (text->len == len) return; if (text->slen + len > text->len) { text->str = xrealloc(text->str, sizeof(chtype) * len + 1); text->len = len; } text->slen = min(len, text->slen); text->str[text->slen] = 0; } static void ui_text_attr_insert(struct ui_text *text, int idx, int attr, const char *str) { size_t slen = strlen(str); uint32_t i, j; if (idx + slen > text->len) ui_text_len_set(text, idx + slen); for (j = 0, i = idx; i < idx + slen; i++, j++) text->str[i] = str[j] | attr; } static void ui_text_free(struct ui_text *text) { xfree(text->str); xfree(text); } void ui_table_init(struct ui_table *tbl) { memset(tbl, 0, sizeof(*tbl)); getsyx(tbl->y, tbl->x); tbl->rows_y = tbl->y; tbl->width = COLS; tbl->height = LINES - 2; tbl->col_pad = 1; tbl->row = ui_text_alloc(tbl->width); INIT_LIST_HEAD(&tbl->cols); } void ui_table_uninit(struct ui_table *tbl) { struct ui_col *col, *tmp; list_for_each_entry_safe(col, tmp, &tbl->cols, entry) xfree(col); ui_text_free(tbl->row); } void ui_table_pos_set(struct ui_table *tbl, int y, int x) { tbl->y = y; tbl->x = x; tbl->rows_y = y; } static struct ui_col *ui_table_col_get(struct ui_table *tbl, uint32_t id) { struct ui_col *col; list_for_each_entry(col, &tbl->cols, entry) { if (col->id == id) return col; } bug(); } static void __ui_table_pos_update(struct ui_table *tbl) { struct ui_col *col; uint32_t pos = 0; list_for_each_entry(col, &tbl->cols, entry) { col->pos = pos; pos += col->len + tbl->col_pad; } } void ui_table_col_add(struct ui_table *tbl, uint32_t id, char *name, uint32_t len) { struct ui_col *col = xzmalloc(sizeof(*col)); col->id = id; col->name = name; col->len = len; col->align = UI_ALIGN_LEFT; list_add_tail(&col->entry, &tbl->cols); __ui_table_pos_update(tbl); } void ui_table_col_color_set(struct ui_table *tbl, int col_id, int color) { struct ui_col *col = ui_table_col_get(tbl, col_id); col->color = color; } void ui_table_col_align_set(struct ui_table *tbl, int col_id, enum ui_align align) { struct ui_col *col = ui_table_col_get(tbl, col_id); col->align = align; } void ui_table_row_add(struct ui_table *tbl) { tbl->rows_y++; } void ui_table_clear(struct ui_table *tbl) { int y; tbl->rows_y = tbl->y; for (y = tbl->y + 1; y < tbl->y + tbl->height; y++) { mvprintw(y, tbl->x, "%*s", tbl->width, " "); } } #define UI_ALIGN_COL(col) (((col)->align == UI_ALIGN_LEFT) ? "%-*.*s" : "%*.*s") void ui_table_row_show(struct ui_table *tbl) { mvaddchstr(tbl->rows_y, tbl->x, tbl->row->str + tbl->scroll_x); ui_text_len_set(tbl->row, 0); } static void __ui_table_row_print(struct ui_table *tbl, struct ui_col *col, int color, const char *str) { char tmp[128]; slprintf(tmp, sizeof(tmp), UI_ALIGN_COL(col), col->len, col->len, str); ui_text_attr_insert(tbl->row, col->pos, color, tmp); slprintf(tmp, sizeof(tmp), "%*s", tbl->col_pad, " "); ui_text_attr_insert(tbl->row, col->pos + col->len, color, tmp); } void ui_table_row_col_set(struct ui_table *tbl, uint32_t col_id, const char *str) { struct ui_col *col = ui_table_col_get(tbl, col_id); __ui_table_row_print(tbl, col, col->color, str); } void ui_table_header_color_set(struct ui_table *tbl, int color) { tbl->hdr_color = color; } void ui_table_height_set(struct ui_table *tbl, int height) { tbl->height = height; } void ui_table_header_print(struct ui_table *tbl) { struct ui_col *col; attron(tbl->hdr_color); mvprintw(tbl->y, tbl->x, "%*s", tbl->width, " "); attroff(tbl->hdr_color); list_for_each_entry(col, &tbl->cols, entry) { __ui_table_row_print(tbl, col, tbl->hdr_color, col->name); } ui_table_row_show(tbl); } #define SCROLL_X_STEP 10 void ui_table_event_send(struct ui_table *tbl, enum ui_event_id evt_id) { if (evt_id == UI_EVT_SCROLL_RIGHT) { tbl->scroll_x += SCROLL_X_STEP; } else if (evt_id == UI_EVT_SCROLL_LEFT) { tbl->scroll_x -= SCROLL_X_STEP; if (tbl->scroll_x < 0) tbl->scroll_x = 0; } } lected'>includemode:
authorLinus Torvalds <torvalds@linux-foundation.org>2016-12-14 11:14:28 -0800
committerLinus Torvalds <torvalds@linux-foundation.org>2016-12-14 11:14:28 -0800
commitce38207f161513ee3d2bd3860489f07ebe65bc78 (patch)
treeb3ad9e8a5e087b91d9f30a314c55df5fa70c142e /Documentation/devicetree
parenta9042defa29a01cc538b742eab047848e9b5ae14 (diff)
parent995c6a7fd9b9212abdf01160f6ce3193176be503 (diff)
Merge tag 'sound-4.10-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/tiwai/sound
Pull sound updates from Takashi Iwai: "No dramatic changes are found in this development cycle, but as usual, many commits are applied in a wide range of drivers. Most of big changes are in ASoC, where a few bits of framework work and quite a lot of cleanups and improvements to existing code have been done. The rest are usual stuff, a few HD-audio and USB-audio quirks and fixes, as well as the drop of kthread usages in the whole subsystem. Below are some highlights: ASoC: - support for stereo DAPM controls - some initial work on the of-graph sound card - regmap conversions of the remaining AC'97 drivers - a new version of the topology ABI; this should be backward compatible - updates / cleanups of rsnd, sunxi, sti, nau8825, samsung, arizona, Intel skylake, atom-sst - new drivers for Cirrus Logic CS42L42, Qualcomm MSM8916-WCD, and Realtek RT5665 USB-audio: - yet another race fix at disconnection - tolerated packet size calculation for some Android devices - quirks for Axe-Fx II, QuickCam, TEAC 501/503 HD-audio: - improvement of Dell pin fixup mapping - quirks for HP Z1 Gen3, Alienware 15 R2 2016 and ALC622 headset mic Misc: - replace all kthread usages with simple works" * tag 'sound-4.10-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/tiwai/sound: (296 commits) ALSA: hiface: Fix M2Tech hiFace driver sampling rate change ALSA: usb-audio: Eliminate noise at the start of DSD playback. ALSA: usb-audio: Add native DSD support for TEAC 501/503 DAC ASoC: wm_adsp: wm_adsp_buf_alloc should use kfree in error path ASoC: topology: avoid uninitialized kcontrol_type ALSA: usb-audio: Add QuickCam Communicate Deluxe/S7500 to volume_control_quirks ALSA: usb-audio: add implicit fb quirk for Axe-Fx II ASoC: zte: spdif: correct ZX_SPDIF_CLK_RAT define ASoC: zte: spdif and i2s drivers are not zx296702 specific ASoC: rsnd: setup BRGCKR/BRRA/BRRB when starting ASoC: rsnd: enable/disable ADG when suspend/resume timing ASoC: rsnd: tidyup ssi->usrcnt counter check in hw_params ALSA: cs46xx: add a new line ASoC: Intel: update bxt_da7219_max98357a to support quad ch dmic capture ASoC: nau8825: disable sinc filter for high THD of ADC ALSA: usb-audio: more tolerant packetsize ALSA: usb-audio: avoid setting of sample rate multiple times on bus ASoC: cs35l34: Simplify the logic to set CS35L34_MCLK_CTL setting ALSA: hda - Gate the mic jack on HP Z1 Gen3 AiO ALSA: hda: when comparing pin configurations, ignore assoc in addition to seq ...
Diffstat (limited to 'Documentation/devicetree')