diff -urNp linux-4.10-rc5.orig/drivers/tty/vt/consolemap.c linux-4.10-rc5/drivers/tty/vt/consolemap.c --- linux-4.10-rc5.orig/drivers/tty/vt/consolemap.c 2017-01-22 20:54:15.000000000 +0000 +++ linux-4.10-rc5/drivers/tty/vt/consolemap.c 2017-01-25 07:00:34.337625600 +0000 @@ -35,7 +35,11 @@ #include #include +#ifdef CONFIG_UNICON +unsigned short translations[][256] = { +#else static unsigned short translations[][256] = { +#endif /* 8-bit Latin-1 mapped to Unicode -- trivial mapping */ { 0x0000, 0x0001, 0x0002, 0x0003, 0x0004, 0x0005, 0x0006, 0x0007, diff -urNp linux-4.10-rc5.orig/drivers/tty/vt/selection.c linux-4.10-rc5/drivers/tty/vt/selection.c --- linux-4.10-rc5.orig/drivers/tty/vt/selection.c 2017-01-22 20:54:15.000000000 +0000 +++ linux-4.10-rc5/drivers/tty/vt/selection.c 2017-01-25 07:00:34.337625600 +0000 @@ -216,6 +216,31 @@ int set_selection(const struct tiocl_sel switch (sel_mode) { case TIOCL_SELCHAR: /* character-by-character selection */ +#ifdef CONFIG_UNICON + { + unsigned char c; + int num = 0; + int ps1 = ps; + + while(1) + { + c = sel_pos(ps1); + if(!(c & 0x80)) + break; + + num++; + if (!(ps1 % vc->vc_size_row)) + break; + ps1 -= 2; + } + if(num != 0) + { + if(num%2) + pe += 2; + else ps -= 2; + } + } +#endif new_sel_start = ps; new_sel_end = pe; break; @@ -224,7 +249,11 @@ int set_selection(const struct tiocl_sel for (new_sel_start = ps; ; ps -= 2) { if ((spc && !isspace(sel_pos(ps))) || +#ifdef CONFIG_UNICON + (!spc && !inword(sel_pos(ps))&& !(sel_pos(ps)&0x80))) +#else (!spc && !inword(sel_pos(ps)))) +#endif break; new_sel_start = ps; if (!(ps % vc->vc_size_row)) @@ -234,7 +263,12 @@ int set_selection(const struct tiocl_sel for (new_sel_end = pe; ; pe += 2) { if ((spc && !isspace(sel_pos(pe))) || +#ifdef CONFIG_UNICON + (!spc && !inword(sel_pos(pe))&& !(sel_pos(pe) & 0x80))) +#else + (!spc && !inword(sel_pos(pe)))) +#endif break; new_sel_end = pe; if (!((pe + 2) % vc->vc_size_row)) diff -urNp linux-4.10-rc5.orig/drivers/tty/vt/vt.c linux-4.10-rc5/drivers/tty/vt/vt.c --- linux-4.10-rc5.orig/drivers/tty/vt/vt.c 2017-01-22 20:54:15.000000000 +0000 +++ linux-4.10-rc5/drivers/tty/vt/vt.c 2017-01-25 07:05:11.916543037 +0000 @@ -100,6 +100,11 @@ #include #include #include +#include +#ifdef CONFIG_UNICON +#include +extern unsigned short translations[][256]; +#endif #include #include @@ -300,6 +305,21 @@ static inline unsigned short *screenpos( return p; } +#ifdef CONFIG_UNICON +static inline unsigned short *screenpos_ext(struct vc_data *vc, int offset, int viewed) +{ + unsigned short *p; + + if (!viewed) + p = (unsigned short *)(vc->vc_origin + offset + vc->vc_screenbuf_size); + else if (!vc->vc_sw->con_screen_pos) + p = (unsigned short *)(vc->vc_visible_origin + offset + vc->vc_screenbuf_size); + else + p = vc->vc_sw->con_screen_pos(vc, -offset-1); + return p; +} +#endif + /* Called from the keyboard irq path.. */ static inline void scrolldelta(int lines) { @@ -336,6 +356,13 @@ static void con_scroll(struct vc_data *v } scr_memmovew(d, s, (b - t - nr) * vc->vc_size_row); scr_memsetw(clear, vc->vc_video_erase_char, vc->vc_size_row * nr); +#ifdef CONFIG_UNICON + d += (vc->vc_screenbuf_size>>1); + s += (vc->vc_screenbuf_size>>1); + scr_memmovew(d, s, (b - t - nr) * vc->vc_size_row); + scr_memsetw(d + (b - t - nr) * vc->vc_cols, (vc->vc_video_erase_char & 0xff), + vc->vc_size_row * nr); +#endif } static void do_update_region(struct vc_data *vc, unsigned long start, int count) @@ -358,6 +385,10 @@ static void do_update_region(struct vc_d int startx = xx; u16 *q = p; while (xx < vc->vc_cols && count) { +#ifdef CONFIG_UNICON + //line by line, so the following putcs will be assured to + //handle only in-line string. +#endif if (attrib != (scr_readw(p) & 0xff00)) { if (p > q) vc->vc_sw->con_putcs(vc, q, p-q, yy, startx); @@ -495,16 +526,30 @@ void invert_screen(struct vc_data *vc, i void complement_pos(struct vc_data *vc, int offset) { static int old_offset = -1; +#ifdef CONFIG_UNICON + static unsigned short old = 0; + static unsigned short oldx = 0, oldy = 0; + static unsigned short *p_ext = NULL; + static unsigned short old_ext = 0; +#else static unsigned short old; static unsigned short oldx, oldy; +#endif WARN_CONSOLE_UNLOCKED(); if (old_offset != -1 && old_offset >= 0 && old_offset < vc->vc_screenbuf_size) { scr_writew(old, screenpos(vc, old_offset, 1)); +#ifdef CONFIG_UNICON + //scr_writew(old_ext, screenpos_ext(vc, old_offset, 1)); +#endif if (con_should_update(vc)) +#ifdef CONFIG_UNICON + vc->vc_sw->con_putc(vc, (old_ext<<16) | old, oldy, oldx); +#else vc->vc_sw->con_putc(vc, old, oldy, oldx); +#endif notify_update(vc); } @@ -515,13 +560,23 @@ void complement_pos(struct vc_data *vc, unsigned short new; unsigned short *p; p = screenpos(vc, offset, 1); +#ifdef CONFIG_UNICON + p_ext = screenpos_ext(vc, offset, 1); +#endif old = scr_readw(p); +#ifdef CONFIG_UNICON + old_ext = scr_readw(p_ext); +#endif new = old ^ vc->vc_complement_mask; scr_writew(new, p); if (con_should_update(vc)) { oldx = (offset >> 1) % vc->vc_cols; oldy = (offset >> 1) / vc->vc_cols; +#ifdef CONFIG_UNICON + vc->vc_sw->con_putc(vc, (old_ext<<16) | new, oldy, oldx); +#else vc->vc_sw->con_putc(vc, new, oldy, oldx); +#endif } notify_update(vc); } @@ -533,6 +588,11 @@ static void insert_char(struct vc_data * scr_memmovew(p + nr, p, (vc->vc_cols - vc->vc_x - nr) * 2); scr_memsetw(p, vc->vc_video_erase_char, nr * 2); +#ifdef CONFIG_UNICON + scr_memmovew(p + nr + (vc->vc_screenbuf_size>>1), p + (vc->vc_screenbuf_size>>1), + (vc->vc_cols - vc->vc_x - nr) * 2); + scr_memsetw(p + (vc->vc_screenbuf_size>>1), (vc->vc_video_erase_char & 0xff), nr * 2); +#endif vc->vc_need_wrap = 0; if (con_should_update(vc)) do_update_region(vc, (unsigned long) p, @@ -544,8 +604,16 @@ static void delete_char(struct vc_data * unsigned short *p = (unsigned short *) vc->vc_pos; scr_memcpyw(p, p + nr, (vc->vc_cols - vc->vc_x - nr) * 2); +#ifdef CONFIG_UNICON + scr_memcpyw(p + (vc->vc_screenbuf_size>>1), p + nr + (vc->vc_screenbuf_size>>1), + (vc->vc_cols - vc->vc_x - nr) * 2); +#endif scr_memsetw(p + vc->vc_cols - vc->vc_x - nr, vc->vc_video_erase_char, nr * 2); +#ifdef CONFIG_UNICON + scr_memsetw(p + vc->vc_cols - vc->vc_x - nr + (vc->vc_screenbuf_size>>1), + (vc->vc_video_erase_char & 0xff), nr * 2); +#endif vc->vc_need_wrap = 0; if (con_should_update(vc)) do_update_region(vc, (unsigned long) p, @@ -568,7 +636,11 @@ static void add_softcursor(struct vc_dat if ((type & 0x40) && ((i & 0x700) == ((i & 0x7000) >> 4))) i ^= 0x0700; scr_writew(i, (u16 *) vc->vc_pos); if (con_should_update(vc)) +#ifdef CONFIG_UNICON + vc->vc_sw->con_putc(vc, scr_readw((u16 *) vc->vc_pos+ (vc->vc_screenbuf_size>>1))<<16 | (i & 0xffff), vc->vc_y, vc->vc_x); +#else vc->vc_sw->con_putc(vc, i, vc->vc_y, vc->vc_x); +#endif } static void hide_softcursor(struct vc_data *vc) @@ -576,8 +648,13 @@ static void hide_softcursor(struct vc_da if (softcursor_original != -1) { scr_writew(softcursor_original, (u16 *)vc->vc_pos); if (con_should_update(vc)) +#ifdef CONFIG_UNICON + vc->vc_sw->con_putc(vc, scr_readw((u16 *) vc->vc_pos+ (vc->vc_screenbuf_size>>1))<<16 | softcursor_original, + vc->vc_y, vc->vc_x); +#else vc->vc_sw->con_putc(vc, softcursor_original, vc->vc_y, vc->vc_x); +#endif softcursor_original = -1; } } @@ -774,7 +851,11 @@ int vc_allocate(unsigned int currcons) / if (!*vc->vc_uni_pagedir_loc) con_set_default_unimap(vc); +#ifdef CONFIG_UNICON + vc->vc_screenbuf = kmalloc(vc->vc_screenbuf_size * 2, GFP_KERNEL); +#else vc->vc_screenbuf = kmalloc(vc->vc_screenbuf_size, GFP_KERNEL); +#endif if (!vc->vc_screenbuf) goto err_free; @@ -835,7 +916,7 @@ static int vc_do_resize(struct tty_struc { unsigned long old_origin, new_origin, new_scr_end, rlth, rrem, err = 0; unsigned long end; - unsigned int old_rows, old_row_size; + unsigned int old_rows, old_row_size, old_screen_size; unsigned int new_cols, new_rows, new_row_size, new_screen_size; unsigned int user; unsigned short *newscreen; @@ -861,7 +942,11 @@ static int vc_do_resize(struct tty_struc if (new_screen_size > (4 << 20)) return -EINVAL; +#ifdef CONFIG_UNICON + newscreen = kmalloc(new_screen_size*2, GFP_USER); +#else newscreen = kmalloc(new_screen_size, GFP_USER); +#endif if (!newscreen) return -ENOMEM; @@ -870,6 +955,9 @@ static int vc_do_resize(struct tty_struc old_rows = vc->vc_rows; old_row_size = vc->vc_size_row; +#ifdef CONFIG_UNICON + old_screen_size = vc->vc_screenbuf_size; +#endif err = resize_screen(vc, new_cols, new_rows, user); if (err) { @@ -911,15 +999,30 @@ static int vc_do_resize(struct tty_struc while (old_origin < end) { scr_memcpyw((unsigned short *) new_origin, (unsigned short *) old_origin, rlth); - if (rrem) +#ifdef CONFIG_UNICON + scr_memcpyw((unsigned short *) (new_origin + new_screen_size), + (unsigned short *) (old_origin + old_screen_size), + rlth); +#endif + if (rrem) { scr_memsetw((void *)(new_origin + rlth), vc->vc_video_erase_char, rrem); +#ifdef CONFIG_UNICON + scr_memsetw((void *)(new_origin + rlth + new_screen_size), + (vc->vc_video_erase_char & 0xff), rrem); +#endif + } old_origin += old_row_size; new_origin += new_row_size; } - if (new_scr_end > new_origin) + if (new_scr_end > new_origin) { scr_memsetw((void *)new_origin, vc->vc_video_erase_char, new_scr_end - new_origin); +#ifdef CONFIG_UNICON + scr_memsetw((void *)(new_origin + new_screen_size), (vc->vc_video_erase_char & 0xff), + new_scr_end - new_origin); +#endif + } kfree(vc->vc_screenbuf); vc->vc_screenbuf = newscreen; vc->vc_screenbuf_size = new_screen_size; @@ -1183,6 +1286,9 @@ static void csi_J(struct vc_data *vc, in return; } scr_memsetw(start, vc->vc_video_erase_char, 2 * count); +#ifdef CONFIG_UNICON + scr_memsetw(start + (vc->vc_screenbuf_size>>1), (vc->vc_video_erase_char & 0xff), 2 * count); +#endif if (con_should_update(vc)) do_update_region(vc, (unsigned long) start, count); vc->vc_need_wrap = 0; @@ -1210,6 +1316,9 @@ static void csi_K(struct vc_data *vc, in return; } scr_memsetw(start, vc->vc_video_erase_char, 2 * count); +#ifdef CONFIG_UNICON + scr_memsetw(start + (vc->vc_screenbuf_size>>1), (vc->vc_video_erase_char & 0xff), 2 * count); +#endif vc->vc_need_wrap = 0; if (con_should_update(vc)) do_update_region(vc, (unsigned long) start, count); @@ -1224,6 +1333,9 @@ static void csi_X(struct vc_data *vc, in count = (vpar > vc->vc_cols - vc->vc_x) ? (vc->vc_cols - vc->vc_x) : vpar; scr_memsetw((unsigned short *)vc->vc_pos, vc->vc_video_erase_char, 2 * count); +#ifdef CONFIG_UNICON + scr_memsetw((unsigned short *)vc->vc_pos + (vc->vc_screenbuf_size>>1), (vc->vc_video_erase_char & 0xff), 2 * count); +#endif if (con_should_update(vc)) vc->vc_sw->con_clear(vc, vc->vc_y, vc->vc_x, 1, count); vc->vc_need_wrap = 0; @@ -1925,7 +2037,13 @@ static void do_con_trol(struct tty_struc if (vc->vc_ques) { clear_selection(); if (vc->vc_par[0]) +#ifdef CONFIG_UNICON + // force the low byte to be zero + + vc->vc_complement_mask = vc->vc_par[0] << 8; +#else vc->vc_complement_mask = vc->vc_par[0] << 8 | vc->vc_par[1]; +#endif else vc->vc_complement_mask = vc->vc_s_complement_mask; return; @@ -2187,6 +2305,12 @@ static int do_con_write(struct tty_struc uint8_t inverse; uint8_t width; u16 himask, charmask; +#ifdef CONFIG_UNICON + /* added by Arthur Ma, for multiple font support */ + struct double_byte * doublebyte_default = NULL; +#define GB_LEFT 0x8000 +#define GB_RIGHT 0xc000 +#endif if (in_interrupt()) return count; @@ -2201,6 +2325,12 @@ static int do_con_write(struct tty_struc return 0; } +#ifdef CONFIG_UNICON + /* added by Arthur Ma, for multiple font support */ + if (UniconFontManager != NULL) + doublebyte_default = UniconFontManager->getfont (vc->vc_num); +#endif + currcons = vc->vc_num; if (!vc_cons_allocated(currcons)) { /* could this happen? */ @@ -2385,6 +2515,58 @@ rescan_last_byte: ((vc_attr << 8) & ~himask) + ((tc & 0x100) ? himask : 0) + (tc & 0xff) : (vc_attr << 8) + tc, (u16 *) vc->vc_pos); +#ifdef CONFIG_UNICON +#define HIGH_WORD ((u16 *) ((long)vc->vc_pos + vc->vc_screenbuf_size)) +#define HIGH_WORD_PREV ((u16 *) ((long)vc->vc_pos - 2 + vc->vc_screenbuf_size)) +#define HIGH_WORD_NEXT ((u16 *) ((long)vc->vc_pos + 2 + vc->vc_screenbuf_size)) + /* + * following condiction we do not tread the char + * as double byte. + * 1. default encoding is NULL. The encode module + * not install yet. + * 2. Current char set is not the default one. + * We are possible drawing a table lines right + * now. + * -Chris + */ + if (doublebyte_default && vc->vc_translate == translations[0] + && (vc->vc_pos==vc->vc_origin||!(scr_readw(HIGH_WORD_PREV)&DB_HALF_MASK)) + && doublebyte_default->is_left(tc)){ + /* + * possible the left char of the Double + * Byte, but we don't know yet, because + * the right char is unknow right now. + * So mark it as Half char, the possible + * candidate + * -Chris + */ + scr_writew(DB_HALF_MASK,HIGH_WORD); + + } else if(doublebyte_default&& vc->vc_translate == translations[0] + && scr_readw(HIGH_WORD_PREV)==DB_HALF_MASK + && doublebyte_default->is_right(tc)) { + scr_writew(DB_LEFT|(tc & 0xff),HIGH_WORD_PREV); + scr_writew(DB_RIGHT|(scr_readw((u16*)(vc->vc_pos-2))&0xff),HIGH_WORD); + if (con_should_update(vc) && draw_x < 0) { + draw_from = vc->vc_pos-2; + if (vc->vc_x>0) { + draw_x = vc->vc_x-1; + } else { + draw_to = vc->vc_pos; + draw_x = vc->vc_cols -1; + vc->vc_y--; + con_flush(vc, draw_from, draw_to, &draw_x); + vc->vc_y++; + draw_x = 0; + draw_from = vc->vc_pos; + } + } + } else if(doublebyte_default) { + /* normal ASCII or table lines, + clean hight byte */ + scr_writew(0,HIGH_WORD); + } +#endif if (con_should_update(vc) && draw_x < 0) { draw_x = vc->vc_x; draw_from = vc->vc_pos; @@ -2442,6 +2624,11 @@ static void console_callback(struct work if (want_console >= 0) { if (want_console != fg_console && vc_cons_allocated(want_console)) { +#ifdef CONFIG_UNICON + extern void (*Unicon_TtyChangeUpdate) (int nTty); + if (Unicon_TtyChangeUpdate != NULL) + (*Unicon_TtyChangeUpdate) (want_console); +#endif hide_cursor(vc_cons[fg_console].d); change_console(vc_cons[want_console].d); /* we only changed when the console had already @@ -2602,6 +2789,9 @@ static void vt_console_print(struct cons continue; } scr_writew((vc->vc_attr << 8) + c, (unsigned short *)vc->vc_pos); +#ifdef CONFIG_UNICON + scr_writew(0, (unsigned short *)vc->vc_pos + (vc->vc_screenbuf_size>>1)); +#endif notify_write(vc, c); cnt++; if (myx == vc->vc_cols - 1) { @@ -2998,7 +3188,11 @@ static int __init con_init(void) INIT_WORK(&vc_cons[currcons].SAK_work, vc_SAK); tty_port_init(&vc->port); visual_init(vc, currcons, 1); +#ifdef CONFIG_UNICON + vc->vc_screenbuf = kzalloc(2 * vc->vc_screenbuf_size, GFP_NOWAIT); +#else vc->vc_screenbuf = kzalloc(vc->vc_screenbuf_size, GFP_NOWAIT); +#endif vc_init(vc, vc->vc_rows, vc->vc_cols, currcons || !vc->vc_sw->con_save_screen); } @@ -4259,6 +4453,12 @@ void putconsxy(struct vc_data *vc, unsig set_cursor(vc); } +#ifdef CONFIG_UNICON +/* + Now, the unicon doesn't support vcs! + To support it, first change the vc_screen.c! +*/ +#endif u16 vcs_scr_readw(struct vc_data *vc, const u16 *org) { if ((unsigned long)org == vc->vc_pos && softcursor_original != -1) @@ -4324,6 +4524,18 @@ EXPORT_SYMBOL_GPL(vc_scrolldelta_helper) * Visible symbols for modules */ +#ifdef CONFIG_UNICON +int (*Unicon_fnKeyHook) + (struct tty_struct *tty, unsigned char ch, char flag) = NULL; +int (*Unicon_fnLowerKeyHook) (unsigned char ch) = NULL; +void (*Unicon_TtyChangeUpdate) (int nTty) = NULL; +EXPORT_SYMBOL(Unicon_fnLowerKeyHook); +EXPORT_SYMBOL(Unicon_fnKeyHook); +EXPORT_SYMBOL(Unicon_TtyChangeUpdate); +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,0)) +EXPORT_SYMBOL(vc_cons); +#endif +#endif EXPORT_SYMBOL(color_table); EXPORT_SYMBOL(default_red); EXPORT_SYMBOL(default_grn); diff -urNp linux-4.10-rc5.orig/drivers/video/console/bitblit.c linux-4.10-rc5/drivers/video/console/bitblit.c --- linux-4.10-rc5.orig/drivers/video/console/bitblit.c 2017-01-22 20:54:15.000000000 +0000 +++ linux-4.10-rc5/drivers/video/console/bitblit.c 2017-01-25 07:00:34.347625561 +0000 @@ -19,6 +19,10 @@ #include #include "fbcon.h" +#ifdef CONFIG_UNICON +#include "unicon.c" +extern struct display fb_display[MAX_NR_CONSOLES]; +#endif /* * Accelerated handlers. */ @@ -201,7 +205,211 @@ static void bit_putcs(struct vc_data *vc kfree(buf); } +#ifdef CONFIG_UNICON +static void bit_putcs_tl(struct vc_data *vc, struct fb_info *info, + const unsigned short *s, int count, int yy, int xx, + int fg, int bg, struct double_byte * doublebyte_default) +{ +/* void (*move_unaligned)(struct fb_info *info, struct fb_pixmap *buf, + u8 *dst, u32 d_pitch, u8 *src, u32 idx, + u32 height, u32 shift_high, u32 shift_low, + u32 mod); + void (*move_aligned)(struct fb_info *info, struct fb_pixmap *buf, + u8 *dst, u32 d_pitch, u8 *src, u32 s_pitch, + u32 height);*/ + unsigned short charmask = vc->vc_hi_font_mask ? 0x1ff : 0xff; + unsigned int width = (vc->vc_font.width + 7) >> 3; + unsigned int cellsize = vc->vc_font.height * width; + unsigned int maxcnt = info->pixmap.size/cellsize; + unsigned int scan_align = info->pixmap.scan_align - 1; + unsigned int buf_align = info->pixmap.buf_align - 1; + unsigned int shift_low = 0, mod = vc->vc_font.width % 8; + unsigned int shift_high = 8, pitch, cnt, size, k; + unsigned int idx = vc->vc_font.width >> 3; + unsigned int attribute = get_attribute(info, scr_readw(s)); + struct fb_image image; + u8 *src, *dst, *buf = NULL; + u_char * fontdata_save; + int index, c,i; + int extendedchar; + fontdata_save = vc->vc_font.data; + + if (attribute) { + buf = kmalloc(cellsize, GFP_KERNEL); + if (!buf) + return; + } + + image.fg_color = fg; + image.bg_color = bg; + + image.dx = xx * vc->vc_font.width; + image.dy = yy * vc->vc_font.height; + image.height = vc->vc_font.height; + image.depth = 1; + + /*if (info->pixmap.outbuf && info->pixmap.inbuf) { + move_aligned = fb_iomove_buf_aligned; + move_unaligned = fb_iomove_buf_unaligned; + } else { + move_aligned = fb_sysmove_buf_aligned; + move_unaligned = fb_sysmove_buf_unaligned; + }*/ + while (count) { + if (count > maxcnt) + cnt = k = maxcnt; + else + cnt = k = count; + + image.width = vc->vc_font.width * cnt; + pitch = ((image.width + 7) >> 3) + scan_align; + pitch &= ~scan_align; + size = pitch * image.height + buf_align; + size &= ~buf_align; + dst = fb_get_buffer_offset(info, &info->pixmap, size); + image.data = dst; + if (mod) { + for(i = 0; i < k; s++, i++){ + c = (scr_readw (hibyte_pos (vc, s)) << 16) | scr_readw (s); + extendedchar = c & (DB_VALIDATE<<16); + if (extendedchar){ + if ( c & (DB_RIGHT_MASK << 16) ) // right half + index = doublebyte_default->font_index((c>>16)&0xff, (c&0xff)) + 16; + else + index = doublebyte_default->font_index((c&0xff),(c>>16)&0xff); + } + if (extendedchar && index >=0 && index < doublebyte_default->charcount){ + vc->vc_font.data = doublebyte_default->font_data +index; + c = (c & 0xff00); + }else{ + c = c & 0xffff; + vc->vc_font.data = fontdata_save; + } + src = vc->vc_font.data + (c&charmask)*cellsize; + + if (attribute) { + update_attr(buf, src, attribute, vc); + src = buf; + } + + fb_pad_unaligned_buffer(dst, pitch, src, idx, + image.height, shift_high, + shift_low, mod); + shift_low += mod; + dst += (shift_low >= 8) ? width : width - 1; + shift_low &= 7; + shift_high = 8 - shift_low; + } + } else { + for(i = 0; i < k; s++, i++){ + c = (scr_readw (hibyte_pos (vc, s)) << 16) | scr_readw (s); + extendedchar = c & (DB_VALIDATE<<16); + if (extendedchar){ + if ( c & (DB_RIGHT_MASK << 16) ) // right half + index = doublebyte_default->font_index((c>>16)&0xff, (c&0xff)) + 16; + else + index = doublebyte_default->font_index((c&0xff),(c>>16)&0xff); + } + if (extendedchar && index >=0 && index < doublebyte_default->charcount){ + vc->vc_font.data = doublebyte_default->font_data +index; + c = (c & 0xff00); + }else{ + c = c & 0xffff; + vc->vc_font.data = fontdata_save; + } + src = vc->vc_font.data + (c&charmask)*cellsize; + + if (attribute) { + update_attr(buf, src, attribute, vc); + src = buf; + } + + fb_pad_aligned_buffer(dst, pitch, src, idx, image.height); + dst += width; + } + } + info->fbops->fb_imageblit(info, &image); + image.dx += cnt * vc->vc_font.width; + count -= cnt; + } + + if (buf) + kfree(buf); + vc->vc_font.data = fontdata_save; +} +static void bit_putcs_wrap(struct vc_data *vc, struct fb_info *info, + const unsigned short *s, int count, int ypos, int xpos, + int fg, int bg) +{ + int n,yy; + struct display *p = &fb_display[vc->vc_num]; + const unsigned short * str = s; + struct double_byte * doublebyte_default = NULL; + + yy = real_y(p, ypos); + + if (UniconFontManager != NULL) + doublebyte_default = UniconFontManager->getfont (vc->vc_num); + + if (!doublebyte_default) + { + bit_putcs(vc, info, s, count, yy, xpos, fg, bg); + return; + } + + /* + * 2009/01/23 + * modified by Toshi for gpm + */ + if(count == 1) + { + u32 extendedchar, index, c; + u8* fontdata_save; + u16 chr[2] = {0, 0}; + + fontdata_save = vc->vc_font.data; + c = (s >= (u16*)vc->vc_origin) && (s < (u16*)vc->vc_scr_end); + c = c ? (scr_readw (hibyte_pos (vc, s)) << 16) | scr_readw (s) : (s[1] << 16) | s[0]; + + extendedchar = c & (DB_VALIDATE<<16); + if (extendedchar) { + if ( c & (DB_RIGHT_MASK << 16)) {// right half + index = doublebyte_default->font_index((c>>16)&0xff, (c&0xff)) + 16; + } else { + index = doublebyte_default->font_index((c&0xff),(c>>16)&0xff); + } + + if (index >=0 && index < doublebyte_default->charcount) { + vc->vc_font.data = doublebyte_default->font_data +index; + c &= 0xff00; + } + } + + chr[0] = (u16)c; + bit_putcs(vc, info, &chr[0], 1, yy, xpos, fg, bg); + + vc->vc_font.data = fontdata_save; + return; + } + + while (count > 0) { + n = fbcon_get_dchar_len (vc, p, str, count); + if (n != 0) + bit_putcs_tl(vc, info, str, n, yy, xpos, + fg, bg, doublebyte_default); + str += n; + xpos += n; + count -= n; + n = fbcon_get_schar_len (vc, p, str, count); + if (n != 0) + bit_putcs(vc, info, str, n, yy, xpos ,fg ,bg); + str += n; + xpos += n; + count -= n; + } +} +#endif static void bit_clear_margins(struct vc_data *vc, struct fb_info *info, int bottom_only) { @@ -244,6 +452,11 @@ static void bit_cursor(struct vc_data *v int attribute, use_sw = (vc->vc_cursor_type & 0x10); int err = 1; char *src; +#ifdef CONFIG_UNICON + int extendedchar = 0; + u_char * fontdata_save; + struct double_byte * doublebyte_default = NULL; +#endif cursor.set = 0; @@ -256,7 +469,33 @@ static void bit_cursor(struct vc_data *v y += softback_lines; } +#ifdef CONFIG_UNICON + if (UniconFontManager != NULL) + doublebyte_default = UniconFontManager->getfont (vc->vc_num); + + fontdata_save = vc->vc_font.data; + if(doublebyte_default != NULL){ + c = (scr_readw (hibyte_pos (vc, (u16 *) vc->vc_pos)) << 16) | + scr_readw((u16 *) vc->vc_pos); + extendedchar = c & (DB_VALIDATE<<16); + if (extendedchar) { + int index; + if ( c & (DB_RIGHT_MASK << 16)) {// right half + index = doublebyte_default->font_index((c>>16)&0xff, (c&0xff)) + 16; + } else { + index = doublebyte_default->font_index((c&0xff),(c>>16)&0xff); + } + if (index >=0 && index < doublebyte_default->charcount) { + vc->vc_font.data = doublebyte_default->font_data +index; + c = (c & 0xff00); + }else c = c & 0xffff; + } else { + c = c & 0xffff; + } + }else c = scr_readw((u16 *) vc->vc_pos); +#else c = scr_readw((u16 *) vc->vc_pos); +#endif attribute = get_attribute(info, c); src = vc->vc_font.data + ((c & charmask) * (w * vc->vc_font.height)); @@ -386,6 +625,10 @@ static void bit_cursor(struct vc_data *v soft_cursor(info, &cursor); ops->cursor_reset = 0; +#ifdef CONFIG_UNICON + if (doublebyte_default != NULL && extendedchar) + vc->vc_font.data = fontdata_save; +#endif } static int bit_update_start(struct fb_info *info) @@ -404,7 +647,11 @@ void fbcon_set_bitops(struct fbcon_ops * { ops->bmove = bit_bmove; ops->clear = bit_clear; +#ifdef CONFIG_UNICON + ops->putcs = bit_putcs_wrap; +#else ops->putcs = bit_putcs; +#endif ops->clear_margins = bit_clear_margins; ops->cursor = bit_cursor; ops->update_start = bit_update_start; diff -urNp linux-4.10-rc5.orig/drivers/video/console/fbcon.c linux-4.10-rc5/drivers/video/console/fbcon.c --- linux-4.10-rc5.orig/drivers/video/console/fbcon.c 2017-01-22 20:54:15.000000000 +0000 +++ linux-4.10-rc5/drivers/video/console/fbcon.c 2017-01-25 07:09:39.098834356 +0000 @@ -92,7 +92,11 @@ enum { FBCON_LOGO_DONTSHOW = -3 /* do not show the logo */ }; +#ifdef CONFIG_UNICON +struct display fb_display[MAX_NR_CONSOLES]; +#else static struct display fb_display[MAX_NR_CONSOLES]; +#endif static signed char con2fb_map[MAX_NR_CONSOLES]; static signed char con2fb_map_boot[MAX_NR_CONSOLES]; @@ -102,7 +106,11 @@ static int logo_lines; enums. */ static int logo_shown = FBCON_LOGO_CANSHOW; /* Software scrollback */ +#ifdef CONFIG_UNICON +int fbcon_softback_size = 32768; +#else static int fbcon_softback_size = 32768; +#endif static unsigned long softback_buf, softback_curr; static unsigned long softback_in; static unsigned long softback_top, softback_end; @@ -189,6 +197,11 @@ static void fbcon_start(void); static void fbcon_exit(void); static struct device *fbcon_device; +#ifdef CONFIG_UNICON +#include +const unsigned short * hibyte_pos(struct vc_data *vc, const unsigned short *p); +#endif + #ifdef CONFIG_FRAMEBUFFER_CONSOLE_ROTATION static inline void fbcon_set_rotation(struct fb_info *info) { @@ -964,7 +977,11 @@ static const char *fbcon_startup(void) if (!softback_buf) { softback_buf = (unsigned long) +#ifdef CONFIG_UNICON + kmalloc(fbcon_softback_size * 2, +#else kmalloc(fbcon_softback_size, +#endif GFP_KERNEL); if (!softback_buf) { fbcon_softback_size = 0; @@ -1273,11 +1290,17 @@ static void fbcon_putcs(struct vc_data * int count, int ypos, int xpos) { struct fb_info *info = registered_fb[con2fb_map[vc->vc_num]]; +#ifndef CONFIG_UNICON struct display *p = &fb_display[vc->vc_num]; +#endif struct fbcon_ops *ops = info->fbcon_par; if (!fbcon_is_inactive(vc, info)) +#ifdef CONFIG_UNICON + ops->putcs(vc, info, s, count, ypos, xpos, +#else ops->putcs(vc, info, s, count, real_y(p, ypos), xpos, +#endif get_color(vc, info, scr_readw(s), 1), get_color(vc, info, scr_readw(s), 0)); } @@ -1287,7 +1310,11 @@ static void fbcon_putc(struct vc_data *v unsigned short chr; scr_writew(c, &chr); +#ifdef CONFIG_UNICON + fbcon_putcs(vc, (unsigned short *)&c, 1, ypos, xpos); +#else fbcon_putcs(vc, &chr, 1, ypos, xpos); +#endif } static void fbcon_clear_margins(struct vc_data *vc, int bottom_only) @@ -1587,11 +1614,17 @@ static void fbcon_redraw_softback(struct unsigned short c; int x = 0; unsigned short attr = 1; +#ifdef CONFIG_UNICON + unsigned short c_ext; +#endif start = s; le = advance_row(s, 1); do { c = scr_readw(s); +#ifdef CONFIG_UNICON + c_ext = scr_readw(hibyte_pos(vc,s)); +#endif if (attr != (c & 0xff00)) { attr = c & 0xff00; if (s > start) { @@ -1601,7 +1634,11 @@ static void fbcon_redraw_softback(struct start = s; } } +#ifdef CONFIG_UNICON + if (c == scr_readw(d) && c_ext == scr_readw(hibyte_pos(vc,d))) { +#else if (c == scr_readw(d)) { +#endif if (s > start) { fbcon_putcs(vc, start, s - start, line, x); @@ -1726,9 +1763,15 @@ static void fbcon_redraw(struct vc_data unsigned short c; int x = 0; unsigned short attr = 1; +#ifdef CONFIG_UNICON + unsigned short c_ext; +#endif do { c = scr_readw(s); +#ifdef CONFIG_UNICON + c_ext = scr_readw(hibyte_pos(vc,s)); +#endif if (attr != (c & 0xff00)) { attr = c & 0xff00; if (s > start) { @@ -1738,7 +1781,11 @@ static void fbcon_redraw(struct vc_data start = s; } } +#ifdef CONFIG_UNICON + if (c == scr_readw(d) && c_ext == scr_readw(hibyte_pos(vc,d))) { +#else if (c == scr_readw(d)) { +#endif if (s > start) { fbcon_putcs(vc, start, s - start, line, x); @@ -1750,6 +1797,9 @@ static void fbcon_redraw(struct vc_data } } scr_writew(c, d); +#ifdef CONFIG_UNICON + scr_writew(scr_readw(s+(vc->vc_screenbuf_size>>1)),d+(vc->vc_screenbuf_size>>1)); +#endif console_conditional_schedule(); s++; d++; @@ -1779,6 +1829,9 @@ static inline void fbcon_softback_note(s while (count) { scr_memcpyw((u16 *) softback_in, p, vc->vc_size_row); +#ifdef CONFIG_UNICON + scr_memcpyw((u16 *)softback_in+(fbcon_softback_size>>1),p+(vc->vc_screenbuf_size>>1),vc->vc_size_row); +#endif count--; p = advance_row(p, 1); softback_in += vc->vc_size_row; @@ -1901,6 +1954,15 @@ static bool fbcon_scroll(struct vc_data (b - count)), vc->vc_video_erase_char, vc->vc_size_row * count); +#ifdef CONFIG_UNICON + /* SCROLL_REDRAW */ + scr_memsetw((unsigned short *) (vc->vc_origin + + vc->vc_size_row * + (b - count) + + vc->vc_screenbuf_size), + vc->vc_video_erase_char & 0xff, + vc->vc_size_row * count); +#endif return true; } break; @@ -1990,6 +2052,15 @@ static bool fbcon_scroll(struct vc_data t), vc->vc_video_erase_char, vc->vc_size_row * count); +#ifdef CONFIG_UNICON + /* SCROLL_REDRAW */ + scr_memsetw((unsigned short *) (vc->vc_origin + + vc->vc_size_row * + t + + vc->vc_screenbuf_size), + vc->vc_video_erase_char & 0xff, + vc->vc_size_row * count); +#endif return true; } } @@ -2689,6 +2760,20 @@ static u16 *fbcon_screen_pos(struct vc_d unsigned long p; int line; +#ifdef CONFIG_UNICON + if (offset < 0) { + offset = -offset - 1; + if (vc->vc_num != fg_console || !softback_lines) + return (u16 *)(vc->vc_origin + offset + vc->vc_screenbuf_size); + line = offset / vc->vc_size_row; + if (line >= softback_lines) + return (u16 *)(vc->vc_origin + offset - softback_lines * vc->vc_size_row + vc->vc_screenbuf_size); + p = softback_curr + offset; + if (p >= softback_end) + p += softback_buf - softback_end; + return (u16 *)(p+fbcon_softback_size); + } +#endif if (vc->vc_num != fg_console || !softback_lines) return (u16 *) (vc->vc_origin + offset); line = offset / vc->vc_size_row; @@ -2796,6 +2881,11 @@ static void fbcon_scrolldelta(struct vc_ q -= vc->vc_size_row; scr_memcpyw((u16 *) q, (u16 *) p, vc->vc_size_row); +#ifdef CONFIG_UNICON + scr_memcpyw((u16* )(q+vc->vc_screenbuf_size), + (u16* )(p+fbcon_softback_size), + vc->vc_size_row); +#endif } softback_in = softback_curr = p; update_region(vc, vc->vc_origin, @@ -3651,4 +3741,9 @@ module_exit(fb_console_exit); #endif +#ifdef CONFIG_UNICON +EXPORT_SYMBOL(con2fb_map); +EXPORT_SYMBOL(fbcon_putc); +#endif + MODULE_LICENSE("GPL"); diff -urNp linux-4.10-rc5.orig/drivers/video/console/unicon.c linux-4.10-rc5/drivers/video/console/unicon.c --- linux-4.10-rc5.orig/drivers/video/console/unicon.c 1970-01-01 00:00:00.000000000 +0000 +++ linux-4.10-rc5/drivers/video/console/unicon.c 2017-01-25 07:00:34.350958881 +0000 @@ -0,0 +1,70 @@ + +#include + +extern int fbcon_softback_size; +DBFontManager *UniconFontManager = NULL; +EXPORT_SYMBOL (UniconFontManager); + +const unsigned short * hibyte_pos(struct vc_data *vc, const unsigned short *p) +{ + unsigned long pos=(long)p; + if (pos >= vc->vc_origin && pos < vc->vc_scr_end) { + /* pos in the vc buffer - Chrisl 99.11.12*/ + return (unsigned short*)(pos+vc->vc_screenbuf_size); + } else if (vc->vc_num == fg_console){ + /*&& softback_lines,because the scroll will first change + softback_lines, then call this function, so it is ignored here + -JimChen 99.11.12*/ + return (unsigned short*)(pos+fbcon_softback_size); + } else { + /* Should not happen */ + printk("Warnning, changing not active console\n"); + return p; + } +} + +static int fbcon_get_dchar_len (struct vc_data *vc, + struct display *p, + const unsigned short *s, int count) +{ + int n, i; + struct double_byte * doublebyte_default = NULL; + unsigned short charmask = vc->vc_hi_font_mask ? 0x1ff : 0xff; + + if (UniconFontManager != NULL) + doublebyte_default = UniconFontManager->getfont (vc->vc_num); + if (!doublebyte_default) + return 0; + + for (n = 0, i = 0; i < count; i++, s++){ + if (doublebyte_default->is_left (*s & charmask) == 1 || + doublebyte_default->is_right (*s & charmask) == 1) + n++; + else + break; + } + return n; +} + +static int fbcon_get_schar_len (struct vc_data *vc, + struct display *p, + const unsigned short *s, int count) +{ + int n, i; + struct double_byte * doublebyte_default = NULL; + unsigned short charmask = vc->vc_hi_font_mask ? 0x1ff : 0xff; + + if (UniconFontManager != NULL) + doublebyte_default = UniconFontManager->getfont (vc->vc_num); + if (!doublebyte_default) + return count; + + for (n = 0, i = 0; i < count; i++, s++){ + if (doublebyte_default->is_left (*s & charmask) == 0 && + doublebyte_default->is_right (*s & charmask) == 0) + n++; + else + break; + } + return n; +} diff -urNp linux-4.10-rc5.orig/drivers/video/fbdev/Kconfig linux-4.10-rc5/drivers/video/fbdev/Kconfig --- linux-4.10-rc5.orig/drivers/video/fbdev/Kconfig 2017-01-22 20:54:15.000000000 +0000 +++ linux-4.10-rc5/drivers/video/fbdev/Kconfig 2017-01-25 07:00:34.354292201 +0000 @@ -237,6 +237,17 @@ config FB_GRVGA ---help--- This enables support for the SVGACTRL framebuffer in the GRLIB IP library from Aeroflex Gaisler. +config UNICON + bool "UNICON console support" + depends on FB + select FRAMEBUFFER_CONSOLE + help + This is UNICON CJK display system lower level driver and API. + Unikey and CJK font modules are included in the UNICON package. + If you want to use UNICON, say Y here. If unsure, say N. + + source "drivers/video/fbdev/unicon/Kconfig" + config FB_CIRRUS tristate "Cirrus Logic support" depends on FB && (ZORRO || PCI) diff -urNp linux-4.10-rc5.orig/drivers/video/fbdev/Makefile linux-4.10-rc5/drivers/video/fbdev/Makefile --- linux-4.10-rc5.orig/drivers/video/fbdev/Makefile 2017-01-22 20:54:15.000000000 +0000 +++ linux-4.10-rc5/drivers/video/fbdev/Makefile 2017-01-25 07:00:34.354292201 +0000 @@ -6,6 +6,10 @@ obj-y += core/ +ifeq ($(CONFIG_UNICON),y) +subdir-m += unicon +endif + obj-$(CONFIG_FB_MACMODES) += macmodes.o obj-$(CONFIG_FB_WMT_GE_ROPS) += wmt_ge_rops.o diff -urNp linux-4.10-rc5.orig/drivers/video/fbdev/unicon/COPYING linux-4.10-rc5/drivers/video/fbdev/unicon/COPYING --- linux-4.10-rc5.orig/drivers/video/fbdev/unicon/COPYING 1970-01-01 00:00:00.000000000 +0000 +++ linux-4.10-rc5/drivers/video/fbdev/unicon/COPYING 2017-01-25 07:00:34.354292201 +0000 @@ -0,0 +1,341 @@ + + GNU GENERAL PUBLIC LICENSE + Version 2, June 1991 + + Copyright (C) 1989, 1991 Free Software Foundation, Inc. + 675 Mass Ave, Cambridge, MA 02139, USA + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + Preamble + + The licenses for most software are designed to take away your +freedom to share and change it. By contrast, the GNU General Public +License is intended to guarantee your freedom to share and change free +software--to make sure the software is free for all its users. This +General Public License applies to most of the Free Software +Foundation's software and to any other program whose authors commit to +using it. (Some other Free Software Foundation software is covered by +the GNU Library General Public License instead.) You can apply it to +your programs, too. + + When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +this service if you wish), that you receive source code or can get it +if you want it, that you can change the software or use pieces of it +in new free programs; and that you know you can do these things. + + To protect your rights, we need to make restrictions that forbid +anyone to deny you these rights or to ask you to surrender the rights. +These restrictions translate to certain responsibilities for you if you +distribute copies of the software, or if you modify it. + + For example, if you distribute copies of such a program, whether +gratis or for a fee, you must give the recipients all the rights that +you have. You must make sure that they, too, receive or can get the +source code. And you must show them these terms so they know their +rights. + + We protect your rights with two steps: (1) copyright the software, and +(2) offer you this license which gives you legal permission to copy, +distribute and/or modify the software. + + Also, for each author's protection and ours, we want to make certain +that everyone understands that there is no warranty for this free +software. If the software is modified by someone else and passed on, we +want its recipients to know that what they have is not the original, so +that any problems introduced by others will not reflect on the original +authors' reputations. + + Finally, any free program is threatened constantly by software +patents. We wish to avoid the danger that redistributors of a free +program will individually obtain patent licenses, in effect making the +program proprietary. To prevent this, we have made it clear that any +patent must be licensed for everyone's free use or not licensed at all. + + The precise terms and conditions for copying, distribution and +modification follow. + + GNU GENERAL PUBLIC LICENSE + TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION + + 0. This License applies to any program or other work which contains +a notice placed by the copyright holder saying it may be distributed +under the terms of this General Public License. The "Program", below, +refers to any such program or work, and a "work based on the Program" +means either the Program or any derivative work under copyright law: +that is to say, a work containing the Program or a portion of it, +either verbatim or with modifications and/or translated into another +language. (Hereinafter, translation is included without limitation in +the term "modification".) Each licensee is addressed as "you". + +Activities other than copying, distribution and modification are not +covered by this License; they are outside its scope. The act of +running the Program is not restricted, and the output from the Program +is covered only if its contents constitute a work based on the +Program (independent of having been made by running the Program). +Whether that is true depends on what the Program does. + + 1. You may copy and distribute verbatim copies of the Program's +source code as you receive it, in any medium, provided that you +conspicuously and appropriately publish on each copy an appropriate +copyright notice and disclaimer of warranty; keep intact all the +notices that refer to this License and to the absence of any warranty; +and give any other recipients of the Program a copy of this License +along with the Program. + +You may charge a fee for the physical act of transferring a copy, and +you may at your option offer warranty protection in exchange for a fee. + + 2. You may modify your copy or copies of the Program or any portion +of it, thus forming a work based on the Program, and copy and +distribute such modifications or work under the terms of Section 1 +above, provided that you also meet all of these conditions: + + a) You must cause the modified files to carry prominent notices + stating that you changed the files and the date of any change. + + b) You must cause any work that you distribute or publish, that in + whole or in part contains or is derived from the Program or any + part thereof, to be licensed as a whole at no charge to all third + parties under the terms of this License. + + c) If the modified program normally reads commands interactively + when run, you must cause it, when started running for such + interactive use in the most ordinary way, to print or display an + announcement including an appropriate copyright notice and a + notice that there is no warranty (or else, saying that you provide + a warranty) and that users may redistribute the program under + these conditions, and telling the user how to view a copy of this + License. (Exception: if the Program itself is interactive but + does not normally print such an announcement, your work based on + the Program is not required to print an announcement.) + +These requirements apply to the modified work as a whole. If +identifiable sections of that work are not derived from the Program, +and can be reasonably considered independent and separate works in +themselves, then this License, and its terms, do not apply to those +sections when you distribute them as separate works. But when you +distribute the same sections as part of a whole which is a work based +on the Program, the distribution of the whole must be on the terms of +this License, whose permissions for other licensees extend to the +entire whole, and thus to each and every part regardless of who wrote it. + +Thus, it is not the intent of this section to claim rights or contest +your rights to work written entirely by you; rather, the intent is to +exercise the right to control the distribution of derivative or +collective works based on the Program. + +In addition, mere aggregation of another work not based on the Program +with the Program (or with a work based on the Program) on a volume of +a storage or distribution medium does not bring the other work under +the scope of this License. + + 3. You may copy and distribute the Program (or a work based on it, +under Section 2) in object code or executable form under the terms of +Sections 1 and 2 above provided that you also do one of the following: + + a) Accompany it with the complete corresponding machine-readable + source code, which must be distributed under the terms of Sections + 1 and 2 above on a medium customarily used for software interchange; or, + + b) Accompany it with a written offer, valid for at least three + years, to give any third party, for a charge no more than your + cost of physically performing source distribution, a complete + machine-readable copy of the corresponding source code, to be + distributed under the terms of Sections 1 and 2 above on a medium + customarily used for software interchange; or, + + c) Accompany it with the information you received as to the offer + to distribute corresponding source code. (This alternative is + allowed only for noncommercial distribution and only if you + received the program in object code or executable form with such + an offer, in accord with Subsection b above.) + +The source code for a work means the preferred form of the work for +making modifications to it. For an executable work, complete source +code means all the source code for all modules it contains, plus any +associated interface definition files, plus the scripts used to +control compilation and installation of the executable. However, as a +special exception, the source code distributed need not include +anything that is normally distributed (in either source or binary +form) with the major components (compiler, kernel, and so on) of the +operating system on which the executable runs, unless that component +itself accompanies the executable. + +If distribution of executable or object code is made by offering +access to copy from a designated place, then offering equivalent +access to copy the source code from the same place counts as +distribution of the source code, even though third parties are not +compelled to copy the source along with the object code. + + 4. You may not copy, modify, sublicense, or distribute the Program +except as expressly provided under this License. Any attempt +otherwise to copy, modify, sublicense or distribute the Program is +void, and will automatically terminate your rights under this License. +However, parties who have received copies, or rights, from you under +this License will not have their licenses terminated so long as such +parties remain in full compliance. + + 5. You are not required to accept this License, since you have not +signed it. However, nothing else grants you permission to modify or +distribute the Program or its derivative works. These actions are +prohibited by law if you do not accept this License. Therefore, by +modifying or distributing the Program (or any work based on the +Program), you indicate your acceptance of this License to do so, and +all its terms and conditions for copying, distributing or modifying +the Program or works based on it. + + 6. Each time you redistribute the Program (or any work based on the +Program), the recipient automatically receives a license from the +original licensor to copy, distribute or modify the Program subject to +these terms and conditions. You may not impose any further +restrictions on the recipients' exercise of the rights granted herein. +You are not responsible for enforcing compliance by third parties to +this License. + + 7. If, as a consequence of a court judgment or allegation of patent +infringement or for any other reason (not limited to patent issues), +conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot +distribute so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you +may not distribute the Program at all. For example, if a patent +license would not permit royalty-free redistribution of the Program by +all those who receive copies directly or indirectly through you, then +the only way you could satisfy both it and this License would be to +refrain entirely from distribution of the Program. + +If any portion of this section is held invalid or unenforceable under +any particular circumstance, the balance of the section is intended to +apply and the section as a whole is intended to apply in other +circumstances. + +It is not the purpose of this section to induce you to infringe any +patents or other property right claims or to contest validity of any +such claims; this section has the sole purpose of protecting the +integrity of the free software distribution system, which is +implemented by public license practices. Many people have made +generous contributions to the wide range of software distributed +through that system in reliance on consistent application of that +system; it is up to the author/donor to decide if he or she is willing +to distribute software through any other system and a licensee cannot +impose that choice. + +This section is intended to make thoroughly clear what is believed to +be a consequence of the rest of this License. + + 8. If the distribution and/or use of the Program is restricted in +certain countries either by patents or by copyrighted interfaces, the +original copyright holder who places the Program under this License +may add an explicit geographical distribution limitation excluding +those countries, so that distribution is permitted only in or among +countries not thus excluded. In such case, this License incorporates +the limitation as if written in the body of this License. + + 9. The Free Software Foundation may publish revised and/or new versions +of the General Public License from time to time. Such new versions will +be similar in spirit to the present version, but may differ in detail to +address new problems or concerns. + +Each version is given a distinguishing version number. If the Program +specifies a version number of this License which applies to it and "any +later version", you have the option of following the terms and conditions +either of that version or of any later version published by the Free +Software Foundation. If the Program does not specify a version number of +this License, you may choose any version ever published by the Free Software +Foundation. + + 10. If you wish to incorporate parts of the Program into other free +programs whose distribution conditions are different, write to the author +to ask for permission. For software which is copyrighted by the Free +Software Foundation, write to the Free Software Foundation; we sometimes +make exceptions for this. Our decision will be guided by the two goals +of preserving the free status of all derivatives of our free software and +of promoting the sharing and reuse of software generally. + + NO WARRANTY + + 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY +FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN +OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES +PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED +OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF +MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS +TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE +PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, +REPAIR OR CORRECTION. + + 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR +REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, +INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING +OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED +TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY +YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER +PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE +POSSIBILITY OF SUCH DAMAGES. + + END OF TERMS AND CONDITIONS + + Appendix: How to Apply These Terms to Your New Programs + + If you develop a new program, and you want it to be of the greatest +possible use to the public, the best way to achieve this is to make it +free software which everyone can redistribute and change under these terms. + + To do so, attach the following notices to the program. It is safest +to attach them to the start of each source file to most effectively +convey the exclusion of warranty; and each file should have at least +the "copyright" line and a pointer to where the full notice is found. + + + Copyright (C) 19yy + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + +Also add information on how to contact you by electronic and paper mail. + +If the program is interactive, make it output a short notice like this +when it starts in an interactive mode: + + Gnomovision version 69, Copyright (C) 19yy name of author + Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. + This is free software, and you are welcome to redistribute it + under certain conditions; type `show c' for details. + +The hypothetical commands `show w' and `show c' should show the appropriate +parts of the General Public License. Of course, the commands you use may +be called something other than `show w' and `show c'; they could even be +mouse-clicks or menu items--whatever suits your program. + +You should also get your employer (if you work as a programmer) or your +school, if any, to sign a "copyright disclaimer" for the program, if +necessary. Here is a sample; alter the names: + + Yoyodyne, Inc., hereby disclaims all copyright interest in the program + `Gnomovision' (which makes passes at compilers) written by James Hacker. + + , 1 April 1989 + Ty Coon, President of Vice + +This General Public License does not permit incorporating your program into +proprietary programs. If your program is a subroutine library, you may +consider it more useful to permit linking proprietary applications with the +library. If this is what you want to do, use the GNU Library General +Public License instead of this License. + diff -urNp linux-4.10-rc5.orig/drivers/video/fbdev/unicon/CREDITS linux-4.10-rc5/drivers/video/fbdev/unicon/CREDITS --- linux-4.10-rc5.orig/drivers/video/fbdev/unicon/CREDITS 1970-01-01 00:00:00.000000000 +0000 +++ linux-4.10-rc5/drivers/video/fbdev/unicon/CREDITS 2017-01-25 07:00:34.354292201 +0000 @@ -0,0 +1,38 @@ +This is at least a partial credits-file of people that have +contributed to the Linux UNICON subsystems, including tools and +drivers. + +The format of this file was shamelessly stolen from the CREDITS file +in the Linux kernel distribution. + +It is sorted by name and formatted to allow easy grepping and +beautification by scripts. The fields are: name (N), email (E), +web-address (W), PGP key ID and fingerprint (P), description (D), and +snail-mail address (S). + +---------- +N: ChenJun +E: jimc@turbolinux.com.cn +D: Original author of unicon display support in the console driver. + Table character etc. + +N: Li Qi Cheng +E: chrisl at gnuchina dot org +D: Original author of unicon display support in the console driver. + +N: Ma Jun +E: arthur.ma@turbolinux.com.cn +D: Original author of input C/S method and international of the + Unicon project + Imm C/S struct architecture + Font Manager & Unikey + Font modules + SmallFont Utility + Unicon Tools + +N: Yu Min Jian +E: yumingjian@china.com +D: Original author of unicon grasp server + +---------- +End of the Linux UNICON CREDITS file. diff -urNp linux-4.10-rc5.orig/drivers/video/fbdev/unicon/ChangeLog.TL linux-4.10-rc5/drivers/video/fbdev/unicon/ChangeLog.TL --- linux-4.10-rc5.orig/drivers/video/fbdev/unicon/ChangeLog.TL 1970-01-01 00:00:00.000000000 +0000 +++ linux-4.10-rc5/drivers/video/fbdev/unicon/ChangeLog.TL 2017-01-25 07:00:34.354292201 +0000 @@ -0,0 +1,59 @@ +2001-05-30 Ma Lin + * Unicon-3.0.3 released + Kernel patches for 2.4.5 and 2.2.19 + 2.4 Kernel patch cleanup, some bugfix. +2001-05-23 Ma Lin + More documents updated. + Unicon startup scripts updated. + Fixed some install problem. +2001-02-27 Ma Lin + unicon-3.0.2pl2 + Documents updated. + Fixed compile problem under gcc2.96. + kernel patches for 2.4.2 and 2.2.19pre15 +2001-02-26 Ma Lin + * unicon-3.0.2 released + fix a few Makefile and spell problems. + add unicon start scripts. +2001-02-19 Ma Lin + rearrange IMM directory structure + update pinyin.map and sysphrase.txt + kernel patch for 2.4.1 + some other bug-fixes and document-updates. +2001-02-15 Ma Lin + add cxterm IMM module and cit files. +2000-11-22 Arthur ma + * unicon-3.0.1 released + fix a bug on GB==>GBK input switch + remove CFLAG "-V2.7.2.3" in Makefile.in + add kernel 2.4-test11 patch + add kernel 2.2.18-pre22 patch + clean up Makefile and configure script. +2000-09-20 Arthur Ma + release 2.4-test8 patch + add usb patch +2000-08-11 Arthur Ma + kernel font manager bugs +2000-06-8 Arthur Ma + fix memeory leak +2000-05-11 Arthur Ma + delete multiple display of the same phrase. +2000-05-08 Arthur Ma + * release unicon1.1 +2000-05-01 Arthur Ma + port to kernel 2.2.15 +2000-04-21 Arthur Ma + fix the unikey to fit Muti-processor +2000-03-21 Arthur Ma + input method C/S +2000-02-21 Arthur Ma + disable the OS forward key (fix bugs about Ctrl-F1) +2000-02-10 Arthur Ma + Keyboard States monitor +1999-09-21 Justin Yu + * First Public Released 0.1 +1999-09-17 + * Add Help +1999-09-07 + * Change the share memory in xl_pinyin.c to + conventional memory diff -urNp linux-4.10-rc5.orig/drivers/video/fbdev/unicon/Kconfig linux-4.10-rc5/drivers/video/fbdev/unicon/Kconfig --- linux-4.10-rc5.orig/drivers/video/fbdev/unicon/Kconfig 1970-01-01 00:00:00.000000000 +0000 +++ linux-4.10-rc5/drivers/video/fbdev/unicon/Kconfig 2017-01-25 07:00:34.354292201 +0000 @@ -0,0 +1,34 @@ +config UNICON_GB + tristate "UNICON GB Font support" + depends on UNICON + default m + +config UNICON_GBK + tristate "UNICON GBK Font support" + depends on UNICON + default m + +config UNICON_BIG5 + tristate "UNICON Big5 Font support" + depends on UNICON + default m + +config UNICON_EUCJP + tristate "UNICON EUC-JP Font support" + depends on UNICON + default m + +config UNICON_JIS + tristate "UNICON JIS Font support" + depends on UNICON + default m + +config UNICON_SJIS + tristate "UNICON Shift-JIS Font support" + depends on UNICON + default m + +config UNICON_KSCM + tristate "UNICON KSCM Font support" + depends on UNICON + default m diff -urNp linux-4.10-rc5.orig/drivers/video/fbdev/unicon/Makefile linux-4.10-rc5/drivers/video/fbdev/unicon/Makefile --- linux-4.10-rc5.orig/drivers/video/fbdev/unicon/Makefile 1970-01-01 00:00:00.000000000 +0000 +++ linux-4.10-rc5/drivers/video/fbdev/unicon/Makefile 2017-01-25 07:00:34.357625522 +0000 @@ -0,0 +1,21 @@ +# Makefile for the UNICON + +unikey-objs := xl_fm.o xl_hzfb.o xl_keyhooks.o xl_keymasks.o xl_unikey.o + +obj-m := unikey.o +obj-$(CONFIG_UNICON_GB) += encode-gb.o +obj-$(CONFIG_UNICON_GBK) += encode-gbk.o +obj-$(CONFIG_UNICON_BIG5) += encode-big5.o +obj-$(CONFIG_UNICON_EUCJP) += encode-eucjp.o +obj-$(CONFIG_UNICON_JIS) += encode-jis.o +obj-$(CONFIG_UNICON_SJIS) += encode-sjis.o +obj-$(CONFIG_UNICON_KSCM) += encode-kscm.o + +unikey.o: $(unikey-objs) + $(LD) -r -o $@ $(unikey-objs) + +ifeq ($(VERSION),2) +ifneq ($(PATCHLEVEL),6) +include $(TOPDIR)/Rules.make +endif +endif diff -urNp linux-4.10-rc5.orig/drivers/video/fbdev/unicon/encode-big5.c linux-4.10-rc5/drivers/video/fbdev/unicon/encode-big5.c --- linux-4.10-rc5.orig/drivers/video/fbdev/unicon/encode-big5.c 1970-01-01 00:00:00.000000000 +0000 +++ linux-4.10-rc5/drivers/video/fbdev/unicon/encode-big5.c 2017-01-25 07:00:34.357625522 +0000 @@ -0,0 +1,85 @@ + +/* + * + * UNICON - The Console Chinese & I18N + * Copyright (c) 1999-2000 + * + * This file is part of UNICON, a console Chinese & I18N + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + * + * See the file COPYING directory of this archive + * Author: see CREDITS + */ + +#include +#include +#include "font_big5_16.h" + +#ifdef MODULE_LICENSE +MODULE_LICENSE("GPL"); +#endif + +static int index_big5(int left, int right) +{ + int rec; + rec = (left - 0xa1) * (0xff - 0x40) + right - 0x40; + return rec << 5; +} + +static int is_hz_left(int c) +{ + return (c >= 0xa1 && c <= 0xfa); +} + +static int is_hz_right(int c) +{ + return (c >= 40 && c <= 0xff); +} + +#ifdef MODULE +static struct double_byte db_big5 = +#else +struct double_byte db_big5 = +#endif +{ + 0, + "BIG5", + is_hz_left, + is_hz_right, + index_big5, + 16,16, + max_big5_16, + font_big5_16 +}; + +#ifdef MODULE +int init_module(void) +{ + if (UniconFontManager == 0) + return 1; + if (UniconFontManager->registerfont (XL_DB_BIG5, &db_big5) == 0) + return 1; + return 0; +} + +void cleanup_module(void) +{ + if (UniconFontManager == 0) + return; + UniconFontManager->unregisterfont (XL_DB_BIG5); +} +#endif + diff -urNp linux-4.10-rc5.orig/drivers/video/fbdev/unicon/encode-eucjp.c linux-4.10-rc5/drivers/video/fbdev/unicon/encode-eucjp.c --- linux-4.10-rc5.orig/drivers/video/fbdev/unicon/encode-eucjp.c 1970-01-01 00:00:00.000000000 +0000 +++ linux-4.10-rc5/drivers/video/fbdev/unicon/encode-eucjp.c 2017-01-25 07:00:34.357625522 +0000 @@ -0,0 +1,93 @@ +/* + * + * UNICON - The Console Chinese & I18N + * Copyright (c) 1999-2000 + * + * This file is part of UNICON, a console Chinese & I18N + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + * + * See the file COPYING directory of this archive + * Author: see CREDITS + */ + +#include +#include +#include "font_eucjp16.h" +#define min1 0xa1 +#define max1 0xfe +// 0x2121 -- 0x7424 + +#ifdef MODULE_LICENSE +MODULE_LICENSE("GPL"); +#endif + +static int index_euc(int left, int right) +{ + if ( left == 0x8E ) + left = 0; + else + left &= 0x7F; + right &= 0x7F; + + if (left > 0x29) + return ((right - 0x40 + (left - 0x25) * 96) << 5); + else + return ((right - 0x20 + (left - 0x20) * 96) << 5); +} + +static int is_hz_left(int c) +{ + return ( c >= min1 && c<=max1); +} + +static int is_hz_right(int c) +{ + return ( c >= min1 && c<=max1); +} + +#ifdef MODULE +static struct double_byte db_eucjp = +#else +struct double_byte db_eucjp = +#endif +{ + 0, + "EUCJP", + is_hz_left, + is_hz_right, + index_euc, + 16,16, + max_jis16, + font_jis16 +}; + +#ifdef MODULE +int init_module(void) +{ + if (UniconFontManager == (DBFontManager *) 0) + return 1; + if (UniconFontManager->registerfont (XL_DB_EUCJP, &db_eucjp) == 0) + return 1; + return 0; +} + +void cleanup_module(void) +{ + if (UniconFontManager == (DBFontManager *) 0) + return; + UniconFontManager->unregisterfont (XL_DB_EUCJP); +} +#endif diff -urNp linux-4.10-rc5.orig/drivers/video/fbdev/unicon/encode-gb.c linux-4.10-rc5/drivers/video/fbdev/unicon/encode-gb.c --- linux-4.10-rc5.orig/drivers/video/fbdev/unicon/encode-gb.c 1970-01-01 00:00:00.000000000 +0000 +++ linux-4.10-rc5/drivers/video/fbdev/unicon/encode-gb.c 2017-01-25 07:00:34.357625522 +0000 @@ -0,0 +1,79 @@ + +/* + * + * UNICON - The Console Chinese & I18N + * Copyright (c) 1999-2000 + * + * This file is part of UNICON, a console Chinese & I18N + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + * + * See the file COPYING directory of this archive + * Author: see CREDITS + */ + +#include +#include +#include "font_gb16.h" +#define min1 0xa1 +#define max1 0xfe + +#ifdef MODULE_LICENSE +MODULE_LICENSE("GPL"); +#endif + +static int index_gb(int left, int right) +{ + return ((left-min1)*94+right-min1) << 5; +} +static int is_hz(int c) +{ + return ( c >= min1 && c<=max1); +} +#ifdef MODULE +static struct double_byte db_gb = +#else +struct double_byte db_gb = +#endif + +{ + 0, + "GB", + is_hz, + is_hz, + index_gb, + 16,16, + max_gb16, + font_gb16 +}; + +#ifdef MODULE +int init_module(void) +{ + if (UniconFontManager == 0) + return 1; + if (UniconFontManager->registerfont (XL_DB_GB, &db_gb) == 0) + return 1; + return 0; +} + +void cleanup_module(void) +{ + if (UniconFontManager == 0) + return; + UniconFontManager->unregisterfont (XL_DB_GB); +} +#endif + diff -urNp linux-4.10-rc5.orig/drivers/video/fbdev/unicon/encode-gbk.c linux-4.10-rc5/drivers/video/fbdev/unicon/encode-gbk.c --- linux-4.10-rc5.orig/drivers/video/fbdev/unicon/encode-gbk.c 1970-01-01 00:00:00.000000000 +0000 +++ linux-4.10-rc5/drivers/video/fbdev/unicon/encode-gbk.c 2017-01-25 07:00:34.357625522 +0000 @@ -0,0 +1,96 @@ +/* + * + * UNICON - The Console Chinese & I18N + * Copyright (c) 1999-2000 + * + * This file is part of UNICON, a console Chinese & I18N + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + * + * See the file COPYING directory of this archive + * Author: see CREDITS + */ + + /************************************************************************** + the GBK standard internal code is + start at 33088 ===> 0x8140 + end at 65279 ===> 0xfeff + Arthur Ma arthur.ma@turbolinux.com.cn + */ + +#include +#include +#include "font_gbk16.h" +#define min1 0x81 +#define max1 0xfe +#define min2 0x40 +#define max2 0xff + +#ifdef MODULE_LICENSE +MODULE_LICENSE("GPL"); +#endif + +static int index_gbk (int left, int right) +{ + int n; + n = (left - 0x81) * 192; + if (right <= 0xff && right >= 0x40) + n += (right - 0x40); + return n << 5; +} + +static int is_hz_left(int c) +{ + return (c >= min1 && c <= max1); +} + +static int is_hz_right(int c) +{ + return (c >= min2 && c <= max2); +} + +#ifdef MODULE +static struct double_byte db_gbk = +#else +struct double_byte db_gbk = +#endif +{ + 0, + "GBK", + is_hz_left, + is_hz_right, + index_gbk, + 16,16, + max_gbk16, + font_gbk16 +}; + +#ifdef MODULE +int init_module(void) +{ + if (UniconFontManager == NULL) + return 1; + if (UniconFontManager->registerfont (XL_DB_GBK, &db_gbk) == 0) + return 1; + return 0; +} + +void cleanup_module(void) +{ + if (UniconFontManager == NULL) + return; + UniconFontManager->unregisterfont (XL_DB_GBK); +} +#endif diff -urNp linux-4.10-rc5.orig/drivers/video/fbdev/unicon/encode-jis.c linux-4.10-rc5/drivers/video/fbdev/unicon/encode-jis.c --- linux-4.10-rc5.orig/drivers/video/fbdev/unicon/encode-jis.c 1970-01-01 00:00:00.000000000 +0000 +++ linux-4.10-rc5/drivers/video/fbdev/unicon/encode-jis.c 2017-01-25 07:00:34.357625522 +0000 @@ -0,0 +1,99 @@ +/* + * + * UNICON - The Console Chinese & I18N + * Copyright (c) 1999-2000 + * + * This file is part of UNICON, a console Chinese & I18N + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + * + * See the file COPYING directory of this archive + * Author: see CREDITS + */ + +/* + * changelog + * Sat Jan 25 2003 Go Taniguchi + * support jisx0213-1 + */ + +#include +#include +#include "font_jis16.h" +// 0x2121 -- 0x7e79 + +#ifdef MODULE_LICENSE +MODULE_LICENSE("GPL"); +#endif + +static int index_jis(int left, int right) +{ + int rec; + left = left & 0x7f; + right = right & 0x7f; + rec = (left - 0x21) * (0x7e - 0x21 + 1) + right - 0x21; + return rec << 5; +} + +static int is_hz_left(int c) +{ + if (c < 0x80) + return 0; + c = c & 0x7f; + return (c >= 0x21 && c <= 0x7e); +} + +static int is_hz_right(int c) +{ + if (c < 0x80) + return 0; + c = c & 0x7f; + return (c >= 21 && c <= 0x7e); +} + +#ifdef MODULE +static struct double_byte db_jis = +#else +struct double_byte db_jis = +#endif +{ + 0, + "JIS", + is_hz_left, + is_hz_right, + index_jis, + 16,16, + max_jis16, + font_jis16 +}; + +#ifdef MODULE +int init_module(void) +{ + if (UniconFontManager == (DBFontManager *) 0) + return 1; + if (UniconFontManager->registerfont (XL_DB_JIS, &db_jis) == 0) + return 1; + return 0; +} + +void cleanup_module(void) +{ + if (UniconFontManager == (DBFontManager *) 0) + return; + UniconFontManager->unregisterfont (XL_DB_JIS); +} +#endif + diff -urNp linux-4.10-rc5.orig/drivers/video/fbdev/unicon/encode-kscm.c linux-4.10-rc5/drivers/video/fbdev/unicon/encode-kscm.c --- linux-4.10-rc5.orig/drivers/video/fbdev/unicon/encode-kscm.c 1970-01-01 00:00:00.000000000 +0000 +++ linux-4.10-rc5/drivers/video/fbdev/unicon/encode-kscm.c 2017-01-25 07:00:34.357625522 +0000 @@ -0,0 +1,99 @@ +/* + * + * UNICON - The Console Chinese & I18N + * Copyright (c) 1999-2000 + * + * This file is part of UNICON, a console Chinese & I18N + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + * + * See the file COPYING directory of this archive + * Author: see CREDITS + */ + +#include +#include +#include "font_kscm16.h" +// 0x2121 -- 0x7d7e + +/* + the KSC5601 standard internal code is + start at 8481 ===> 0x2121 + end at 32126 ===> 0x7d7e +*/ + +#ifdef MODULE_LICENSE +MODULE_LICENSE("GPL"); +#endif + +static int index_kscm(int left, int right) +{ + int rec; + left = left & 0x7f; + right = right & 0x7f; + rec = (left - 0x21) * (0x7e - 0x21 + 1) + right - 0x21; + return rec << 5; +} + +static int is_hz_left(int c) +{ + if (c < 0x80) + return 0; + c = c & 0x7f; + return (c >= 0x21 && c <= 0x7d); +} + +static int is_hz_right(int c) +{ + if (c < 0x80) + return 0; + c = c & 0x7f; + return (c >= 21 && c <= 0x7e); +} + +#ifdef MODULE +static struct double_byte db_kscm = +#else +struct double_byte db_kscm = +#endif +{ + 0, + "kscm", + is_hz_left, + is_hz_right, + index_kscm, + 16,16, + max_kscm16, + font_kscm16 +}; + +#ifdef MODULE +int init_module(void) +{ + if (UniconFontManager == 0) + return 1; + if (UniconFontManager->registerfont (XL_DB_KSCM, &db_kscm) == 0) + return 1; + return 0; +} + +void cleanup_module(void) +{ + if (UniconFontManager == 0) + return; + UniconFontManager->unregisterfont (XL_DB_KSCM); +} +#endif + diff -urNp linux-4.10-rc5.orig/drivers/video/fbdev/unicon/encode-sjis.c linux-4.10-rc5/drivers/video/fbdev/unicon/encode-sjis.c --- linux-4.10-rc5.orig/drivers/video/fbdev/unicon/encode-sjis.c 1970-01-01 00:00:00.000000000 +0000 +++ linux-4.10-rc5/drivers/video/fbdev/unicon/encode-sjis.c 2017-01-25 07:00:34.357625522 +0000 @@ -0,0 +1,111 @@ +/* + * + * UNICON - The Console Chinese & I18N + * Copyright (c) 1999-2000 + * + * This file is part of UNICON, a console Chinese & I18N + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + * + * See the file COPYING directory of this archive + * Author: see CREDITS + */ + +#include +#include +#include "font_eucjp16.h" +#define min1 0x81 +#define max1 0xfc +// 0x2121 -- 0x7424 + +#ifdef MODULE_LICENSE +MODULE_LICENSE("GPL"); +#endif + +static int is_hz_left(int c) +{ + return ((c >= 0x81 && c <= 0x9f) || (c >= 0xe0 && c <= 0xfc)); +} + +static int is_hz_right(int c) +{ + return ((c >= 0x40 && c <= 0x7e) || (c >= 0x80 && c <= 0xfc)); +} + +static int index_sjis(int left, int right) +{ + int ch1, ch2; + + if ( !is_hz_left(left) || !is_hz_right(right) ) return -512; + + ch1 = left; + ch2 = right; + + if ( ch1 <= 0x9f ) + ch1 -= 0x71; + else + ch1 -= 0xb1; + ch1 *= 2; + ++ch1; + + if ( ch2 >= 0x7f ) + --ch2; + if ( ch2 >= 0x9e ) { + ch2 -= 0x7d; + ++ch1; + } else { + ch2 -= 0x1f; + } + + if (ch1 > 0x29) + return ((ch2 - 0x40 + (ch1 - 0x25) * 96) << 5); + else + return ((ch2 - 0x20 + (ch1 - 0x20) * 96) << 5); +} + +#ifdef MODULE +static struct double_byte db_sjis = +#else +struct double_byte db_sjis = +#endif +{ + 0, + "SJIS", + is_hz_left, + is_hz_right, + index_sjis, + 16,16, + max_jis16, + font_jis16 +}; + +#ifdef MODULE +int init_module(void) +{ + if (UniconFontManager == (DBFontManager *) 0) + return 1; + if (UniconFontManager->registerfont (XL_DB_SJIS, &db_sjis) == 0) + return 1; + return 0; +} + +void cleanup_module(void) +{ + if (UniconFontManager == (DBFontManager *) 0) + return; + UniconFontManager->unregisterfont (XL_DB_SJIS); +} +#endif + diff -urNp linux-4.10-rc5.orig/drivers/video/fbdev/unicon/unikey.h linux-4.10-rc5/drivers/video/fbdev/unicon/unikey.h --- linux-4.10-rc5.orig/drivers/video/fbdev/unicon/unikey.h 1970-01-01 00:00:00.000000000 +0000 +++ linux-4.10-rc5/drivers/video/fbdev/unicon/unikey.h 2017-01-25 07:00:34.357625522 +0000 @@ -0,0 +1,106 @@ +/* + * + * UNICON - The Console Chinese & I18N + * Copyright (c) 1999-2000 + * + * This file is part of UNICON, a console Chinese & I18N + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + * + * See the file COPYING directory of this archive + * Author: see CREDITS + */ + +#ifndef UNIDEV_H +#define UNIDEV_H + +#include +#include +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,15,0)) +#include "../../console/fbcon.h" +#elif (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0)) +#include "../console/fbcon.h" +#endif + +typedef struct __ChinesePut_T__ +{ + int x, y; + unsigned char c1, c2; + long cl; +} +ChinesePut_T; + +typedef struct __AsciiPut_T__ +{ + int x, y; + unsigned char ch; + long cl; +} +AsciiPut_T; + +typedef struct __VtInfo_T__ +{ + int vt_has_resized; + int width, height; +} +VtInfo_T; + +typedef struct __VtFont_T__ +{ + int tty; + int font_type; + int input_method_notify; +} VtFont_T; + +#define DEVICE_FILE_NAME "/dev/unikey" +#define MAJOR_NUM 10 +#define MINOR_NUM 202 +#define UNIKEY_IOCTL 100 +#define UNI_INPUT_GET_INFO _IOR(UNIKEY_IOCTL, 0, char *) +#define UNI_INPUT_SET_INFO _IOR(UNIKEY_IOCTL, 1, char *) +#define UNI_INPUT_REGISTER _IOR(UNIKEY_IOCTL, 2, char *) +#define UNI_INPUT_UNREGISTER _IOR(UNIKEY_IOCTL, 3, char *) + +#define UNI_INPUT_PUT_ASCII _IOR(UNIKEY_IOCTL, 4, AsciiPut_T *) +#define UNI_INPUT_PUT_CHINESE _IOR(UNIKEY_IOCTL, 5, ChinesePut_T *) +#define UNI_INPUT_CLS_BOTTOM _IOR(UNIKEY_IOCTL, 6, char *) +#define UNI_INPUT_GET_VT_INFO _IOR(UNIKEY_IOCTL, 7, VtInfo_T *) + +#define UNI_INPUT_SET_CUR_TTY _IOR(UNIKEY_IOCTL, 8, VtInfo_T *) +#define UNI_INPUT_SET_RESIZE_FLAG _IOR(UNIKEY_IOCTL, 9, char *) +#define UNI_INPUT_SET_UNRESIZE_FLAG _IOR(UNIKEY_IOCTL, 10, char *) +#define UNI_SET_CURRENT_FONT _IOR(UNIKEY_IOCTL, 11, VtFont_T *) + +#define MAXTTYS 6 +#define SUCCESS 0 +#define DEVICE_NAME "unikey" +#define BUF_LEN 80 +#define MAX_CHAR 8 + +/* op */ +#define FLUSH_BOTTOM 1 +#define FLUSH_INPUTMETHOD 2 + +typedef struct __TTY_KEY_T__ +{ + u_char nTty; + u_char op; //bFlushInput; + u_char buf[MAX_CHAR]; + u_char nTotal; +} +TTY_KEY_T; +extern int nCurTty; +#endif + diff -urNp linux-4.10-rc5.orig/drivers/video/fbdev/unicon/xl_fm.c linux-4.10-rc5/drivers/video/fbdev/unicon/xl_fm.c --- linux-4.10-rc5.orig/drivers/video/fbdev/unicon/xl_fm.c 1970-01-01 00:00:00.000000000 +0000 +++ linux-4.10-rc5/drivers/video/fbdev/unicon/xl_fm.c 2017-01-25 07:00:34.357625522 +0000 @@ -0,0 +1,186 @@ +/* + * + * UNICON - The Console Chinese & I18N + * Copyright (c) 1999-2000 + * + * This file is part of UNICON, a console Chinese & I18N + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + * + * See the file COPYING directory of this archive + * Author: see CREDITS + */ + +/* This is the main entry of font manager of UNICON */ + +#include +#include +#include +#include +#include +#include +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,0)) +#include +#endif +#include + + +// #define __XL_DEBUG__ +typedef struct DBFontRegister_T +{ + int font_type; + struct double_byte *p; +} DBFont; + +static DBFont TtyDbFont[MAX_TTY]; +static DBFont aDbFont[MAX_FONT]; + +static void XL_InitDBFont (void); +static int XL_RegisterDBFont (int font_type, struct double_byte *p); +static int XL_UnregisterDBFont (int font_type); +static int XL_IsAvailable (int font_type); +static struct double_byte *XL_GetTtyDBFont (int tty); +static int XL_SetTtyDbFont (int tty, int font_type); +static void ReleaseAllTtyFont (int font_type); + +static void XL_InitDBFont () +{ +#ifdef __XL_DEBUG__ + printk ("XL_InitDBFont () \n"); +#endif + memset (aDbFont, 0, sizeof (aDbFont) * MAX_FONT); + memset (TtyDbFont, 0, sizeof (TtyDbFont) * MAX_TTY); +} + +static int XL_RegisterDBFont (int font_type, struct double_byte *p) +{ +#ifdef __XL_DEBUG__ + printk ("XL_RegisterDBFont (font_type=%d, double_byte=0x%x)\n", font_type, (long) p); +#endif + if (font_type < 0 || font_type >= MAX_FONT) + return 0; + if (aDbFont[font_type].p != NULL) + return 0; + aDbFont[font_type].font_type = font_type; + aDbFont[font_type].p = p; + return 1; +} + +static int XL_UnregisterDBFont (int font_type) +{ +#ifdef __XL_DEBUG__ + printk ("XL_UnregisterDBFont (font_type=%d)\n", font_type); +#endif + if (font_type < 0 || font_type >= MAX_FONT) + return 0; + ReleaseAllTtyFont (font_type); + memset (&aDbFont[font_type], 0, sizeof (DBFont)); + return 1; +} + +static int XL_IsAvailable (int font_type) +{ +#ifdef __XL_DEBUG__ + printk ("XL_IsAvailable (font_type=%d)\n", font_type); +#endif + if (font_type < 0 || font_type >= MAX_FONT) + return 0; + if (aDbFont[font_type].p != NULL) + return 1; + return 0; +} + +static struct double_byte *XL_GetTtyDBFont (int tty) +{ +#ifdef __XL_DEBUG__ + printk ("XL_GetTtyDBFont (tty=%d)\n", tty); +#endif + if (tty < 0 || tty >= MAX_TTY) + return NULL; + if (TtyDbFont[tty].p != NULL) + return TtyDbFont[tty].p; + else + return NULL; +} + +static int XL_SetTtyDbFont (int tty, int font_type) +{ +#ifdef __XL_DEBUG__ + printk ("XL_SetTtyDBFont (tty=%d, font_type=%d)\n", tty, font_type); +#endif + if (font_type < 0 || font_type >= MAX_FONT) + return 0; + if (tty < 0 || tty >= MAX_TTY) + return 0; + if (XL_IsAvailable (font_type) == 0) + return 0; + TtyDbFont[tty].font_type = font_type; + TtyDbFont[tty].p = aDbFont[font_type].p; + return 1; +} + +static void ReleaseAllTtyFont (int font_type) +{ + int i; +#ifdef __XL_DEBUG__ + printk ("ReleaseAllTtyFont (font_type=%d)\n", font_type); +#endif + if (font_type < 0 || font_type >= MAX_FONT) + return; + for (i = 0; i < MAX_TTY; i++) + { + if (TtyDbFont[i].font_type == font_type) + memset (&TtyDbFont[i], 0, sizeof (DBFont)); + } +} + +static DBFontManager UniconFontManagerAbc = +{ + /* init */ + XL_InitDBFont, /* init */ + + /* font manager */ + XL_RegisterDBFont, /* register */ + XL_UnregisterDBFont, /* unregister */ + XL_IsAvailable, /* test available */ + + /* tty font manager */ + XL_GetTtyDBFont, + XL_SetTtyDbFont, +}; + +void UniconFontManagerOpen (void) +{ +#ifdef __XL_DEBUG__ + printk ("void UniconFontManagerOpen ()\n"); +#endif + UniconFontManager = &UniconFontManagerAbc; +} + +void UniconFontManagerClose (void) +{ +#ifdef __XL_DEBUG__ + printk ("void UniconFontManagerClose ()\n"); +#endif +/* + ReleaseAllTtyFont (XL_DB_GB); + ReleaseAllTtyFont (XL_DB_GBK); + ReleaseAllTtyFont (XL_DB_BIG5); + ReleaseAllTtyFont (XL_DB_JIS); + ReleaseAllTtyFont (XL_DB_KSCM); + */ + UniconFontManager = 0; +} + diff -urNp linux-4.10-rc5.orig/drivers/video/fbdev/unicon/xl_funckeys.h linux-4.10-rc5/drivers/video/fbdev/unicon/xl_funckeys.h --- linux-4.10-rc5.orig/drivers/video/fbdev/unicon/xl_funckeys.h 1970-01-01 00:00:00.000000000 +0000 +++ linux-4.10-rc5/drivers/video/fbdev/unicon/xl_funckeys.h 2017-01-25 07:00:34.357625522 +0000 @@ -0,0 +1,54 @@ +/* + * + * UNICON - The Console Chinese & I18N + * Copyright (c) 1999-2000 + * + * This file is part of UNICON, a console Chinese & I18N + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + * + * See the file COPYING directory of this archive + * Author: see CREDITS + */ + +#ifndef __XL_FUNCKEY_H__ +#define __XL_FUNCKEY_H__ +/* + printscreen 0xe0, 0xe0, 0x37, 0xe0, 0xb7, 0xe0 + pause break 0xe1 0x45, 0xe1, 0xc5 + insert 0xe0 0x52 0xe0 0xd2 + home 0xe0 0x47 0xe0 0xc7 + pageup 0xe0 0x49 0xe0 0x79 + delete 0xe0 0x53 0xe0 0xd3 + end 0xe0 0x4f 0xe0 0xcf + pagedown 0xe0 0x51 0xe0 0xd1 + up 0xe0 0x48 0xe0 0xc8 + down 0xe0 0x50 0xe0 0xd0 + left 0xe0 0x4b 0xe0 0xcb + right 0xe0 0x4d 0xe0 0xcd + wakeup 0xe0 0x63 0xe0 0xe3 + sleep 0xe0 0x5f 0xe0 0xdf + power 0xe0 0x5e 0xe0 0xde + / 0xe0 0x35 0xe0 0xb5 + right enter 0xe0 0x1c 0xe0 0x9c + windows special keys support + left1 0xe0 0x5b 0xe0 0xdb + right1 0xe0 0x5c 0xe0 0xdc + right2 0xe0 0x5d 0xe0 0xdd +*/ + scrolllock 0x46, 0xc6 + numlock 0x45 0xc5 +#endif + diff -urNp linux-4.10-rc5.orig/drivers/video/fbdev/unicon/xl_hzfb.c linux-4.10-rc5/drivers/video/fbdev/unicon/xl_hzfb.c --- linux-4.10-rc5.orig/drivers/video/fbdev/unicon/xl_hzfb.c 1970-01-01 00:00:00.000000000 +0000 +++ linux-4.10-rc5/drivers/video/fbdev/unicon/xl_hzfb.c 2017-01-25 07:00:34.357625522 +0000 @@ -0,0 +1,156 @@ +/* + * + * UNICON - The Console Chinese & I18N + * Copyright (c) 1999-2000 + * + * This file is part of UNICON, a console Chinese & I18N + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + * + * See the file COPYING directory of this archive + * Author: see CREDITS + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,0)) +#include +#endif +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,15,0)) +#include "../../console/fbcon.h" +#elif (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0)) +#include "../console/fbcon.h" +#elif (LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,0)) +#include