fbcon: Move bitops callbacks into separate struct
Subsystems (3)
Thomas Zimmermann
maintainerv2 cover fbcon: Move bitops callbacks into separate struct
Instances of fbcon use a number callbacks to support tile-based drawing or console rotation. The fields are writeable in struct fbcon_ops. Each case; unrotated, various rotated and tile-based drawing; uses a set of related calbacks. Updating these 'bitops' at runtime is spread throughout various helper functions.
This series puts related callbacks into dedicated instances of the new type struct fbcon_bitops. Changing the callbacks at runtime then only requires to pick the correct instance. It further allows the various struct fbcon_bitops' to be declared 'static const', which makes them write-protected at runtime.
v2:
- rename struct fbcon_ops to struct fbcon_par
- drop patch 6
Thomas Zimmermann (5):
fbcon: Fix empty lines in fbcon.h
fbcon: Rename struct fbcon_ops to struct fbcon_par
fbcon: Set rotate_font callback with related callbacks
fbcon: Move fbcon callbacks into struct fbcon_bitops
fbcon: Streamline setting rotated/unrotated bitops
drivers/video/fbdev/core/bitblit.c | 122 +++---- drivers/video/fbdev/core/fbcon.c | 459 ++++++++++++------------ drivers/video/fbdev/core/fbcon.h | 17 +- drivers/video/fbdev/core/fbcon_ccw.c | 151 ++++---- drivers/video/fbdev/core/fbcon_cw.c | 151 ++++---- drivers/video/fbdev/core/fbcon_rotate.c | 47 +-- drivers/video/fbdev/core/fbcon_rotate.h | 18 +- drivers/video/fbdev/core/fbcon_ud.c | 167 ++++----- drivers/video/fbdev/core/softcursor.c | 18 +- drivers/video/fbdev/core/tileblit.c | 32 +- 10 files changed, 604 insertions(+), 578 deletions(-)
Signature · 1 line
2.51.0
Thomas Zimmermann
maintainerPATCH v2 1/5 fbcon: Fix empty lines in fbcon.h
Add and remove empty lines as necessary to fix coding style. No functional changes.
--- drivers/video/fbdev/core/fbcon.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/video/fbdev/core/fbcon.h +1 -1
@@ -87,6 +87,7 @@ struct fbcon_ops {u32 cursor_size;u32 fd_size; }; +/* * Attribute Decoding */
@@ -106,7 +107,6 @@ struct fbcon_ops { ((s) & 0x400)#define attr_blink (s) \ ((s) & 0x8000) -static inline int mono_col (const struct fb_info *info) {
Signature · 1 line
2.51.0
Thomas Zimmermann
maintainerPATCH v2 2/5 fbcon: Rename struct fbcon_ops to struct fbcon_par
In reply to Thomas ZimmermannThe type struct fbcon_ops contains fbcon state and callbacks. As the callbacks will be removed from struct fbcon_ops, rename the data type to struct fbcon_par. Also rename the variables from ops to par.
The _par postfix ("private access registers") is used throughout the fbdev subsystem for per-driver state. The fbcon pointer within struct fb_info is also named fbcon_par. Hence, the new naming fits existing practice.
v2:
- rename struct fbcon_ops to struct fbcon_par
- fix build for CONFIG_FB_TILEBITTING=n (kernel test robot)
- fix indention
--- drivers/video/fbdev/core/bitblit.c | 122 +++---- drivers/video/fbdev/core/fbcon.c | 419 ++++++++++++------------ drivers/video/fbdev/core/fbcon.h | 6 +- drivers/video/fbdev/core/fbcon_ccw.c | 146 ++++----- drivers/video/fbdev/core/fbcon_cw.c | 146 ++++----- drivers/video/fbdev/core/fbcon_rotate.c | 40 +-- drivers/video/fbdev/core/fbcon_rotate.h | 6 +- drivers/video/fbdev/core/fbcon_ud.c | 162 ++++----- drivers/video/fbdev/core/softcursor.c | 18 +- drivers/video/fbdev/core/tileblit.c | 28 +- 10 files changed, 541 insertions(+), 552 deletions(-)
drivers/video/fbdev/core/bitblit.c +61 -61
@@ -236,10 +236,10 @@ static void bit_cursor(struct vc_data *vc, struct fb_info *info, bool enable, int fg, int bg) {struct fb_cursor cursor; -struct fbcon_ops *ops = info->fbcon_par; +struct fbcon_par *par = info->fbcon_par;unsigned short charmask = vc->vc_hi_font_mask ?0x1ff :0xff ;int w =DIV_ROUND_UP (vc->vc_font.width,8 ), c; -int y =real_y (ops->p, vc->state.y); +int y =real_y (par->p, vc->state.y);int attribute, use_sw = vc->vc_cursor_type &CUR_SW ;int err =1 ;char *src;
@@ -253,10 +253,10 @@ static void bit_cursor(struct vc_data *vc, struct fb_info *info, bool enable, attribute =get_attribute (info, c); src = vc->vc_font.data + ((c & charmask) * (w * vc->vc_font.height)); -if (ops->cursor_state.image.data != src || - ops->cursor_reset) { - ops->cursor_state.image.data = src; - cursor.set |=FB_CUR_SETIMAGE ; +if (par->cursor_state.image.data != src || + par->cursor_reset) { + par->cursor_state.image.data = src; + cursor.set |=FB_CUR_SETIMAGE ; }if (attribute) {
@@ -265,46 +265,46 @@ static void bit_cursor(struct vc_data *vc, struct fb_info *info, bool enable, dst =kmalloc_array (w, vc->vc_font.height,GFP_ATOMIC );if (!dst)return ; -kfree (ops->cursor_data); - ops->cursor_data = dst; +kfree (par->cursor_data); + par->cursor_data = dst;update_attr (dst, src, attribute, vc); src = dst; } -if (ops->cursor_state.image.fg_color != fg || - ops->cursor_state.image.bg_color != bg || - ops->cursor_reset) { - ops->cursor_state.image.fg_color = fg; - ops->cursor_state.image.bg_color = bg; +if (par->cursor_state.image.fg_color != fg || + par->cursor_state.image.bg_color != bg || + par->cursor_reset) { + par->cursor_state.image.fg_color = fg; + par->cursor_state.image.bg_color = bg; cursor.set |=FB_CUR_SETCMAP ; } -if ((ops->cursor_state.image.dx != (vc->vc_font.width * vc->state.x)) || - (ops->cursor_state.image.dy != (vc->vc_font.height * y)) || - ops->cursor_reset) { - ops->cursor_state.image.dx = vc->vc_font.width * vc->state.x; - ops->cursor_state.image.dy = vc->vc_font.height * y; +if ((par->cursor_state.image.dx != (vc->vc_font.width * vc->state.x)) || + (par->cursor_state.image.dy != (vc->vc_font.height * y)) || + par->cursor_reset) { + par->cursor_state.image.dx = vc->vc_font.width * vc->state.x; + par->cursor_state.image.dy = vc->vc_font.height * y; cursor.set |=FB_CUR_SETPOS ; } -if (ops->cursor_state.image.height != vc->vc_font.height || - ops->cursor_state.image.width != vc->vc_font.width || - ops->cursor_reset) { - ops->cursor_state.image.height = vc->vc_font.height; - ops->cursor_state.image.width = vc->vc_font.width; +if (par->cursor_state.image.height != vc->vc_font.height || + par->cursor_state.image.width != vc->vc_font.width || + par->cursor_reset) { + par->cursor_state.image.height = vc->vc_font.height; + par->cursor_state.image.width = vc->vc_font.width; cursor.set |=FB_CUR_SETSIZE ; } -if (ops->cursor_state.hot.x || ops->cursor_state.hot.y || - ops->cursor_reset) { - ops->cursor_state.hot.x = cursor.hot.y =0 ; +if (par->cursor_state.hot.x || par->cursor_state.hot.y || + par->cursor_reset) { + par->cursor_state.hot.x = cursor.hot.y =0 ; cursor.set |=FB_CUR_SETHOT ; }if (cursor.set &FB_CUR_SETSIZE || - vc->vc_cursor_type != ops->p->cursor_shape || - ops->cursor_state.mask ==NULL || - ops->cursor_reset) { + vc->vc_cursor_type != par->p->cursor_shape || + par->cursor_state.mask ==NULL || + par->cursor_reset) {char *mask =kmalloc_array (w, vc->vc_font.height,GFP_ATOMIC );int cur_height, size, i =0 ;u8 msk =0xff ;
@@ -312,13 +312,13 @@ static void bit_cursor(struct vc_data *vc, struct fb_info *info, bool enable,if (!mask)return ; -kfree (ops->cursor_state.mask); - ops->cursor_state.mask = mask; +kfree (par->cursor_state.mask); + par->cursor_state.mask = mask; - ops->p->cursor_shape = vc->vc_cursor_type; + par->p->cursor_shape = vc->vc_cursor_type; cursor.set |=FB_CUR_SETSHAPE ; -switch (CUR_SIZE (ops->p->cursor_shape)) { +switch (CUR_SIZE (par->p->cursor_shape)) {case CUR_NONE : cur_height =0 ;break ;
@@ -347,19 +347,19 @@ static void bit_cursor(struct vc_data *vc, struct fb_info *info, bool enable, mask[i++] = msk; } - ops->cursor_state.enable = enable && !use_sw; + par->cursor_state.enable = enable && !use_sw; cursor.image.data = src; - cursor.image.fg_color = ops->cursor_state.image.fg_color; - cursor.image.bg_color = ops->cursor_state.image.bg_color; - cursor.image.dx = ops->cursor_state.image.dx; - cursor.image.dy = ops->cursor_state.image.dy; - cursor.image.height = ops->cursor_state.image.height; - cursor.image.width = ops->cursor_state.image.width; - cursor.hot.x = ops->cursor_state.hot.x; - cursor.hot.y = ops->cursor_state.hot.y; - cursor.mask = ops->cursor_state.mask; - cursor.enable = ops->cursor_state.enable; + cursor.image.fg_color = par->cursor_state.image.fg_color; + cursor.image.bg_color = par->cursor_state.image.bg_color; + cursor.image.dx = par->cursor_state.image.dx; + cursor.image.dy = par->cursor_state.image.dy; + cursor.image.height = par->cursor_state.image.height; + cursor.image.width = par->cursor_state.image.width; + cursor.hot.x = par->cursor_state.hot.x; + cursor.hot.y = par->cursor_state.hot.y; + cursor.mask = par->cursor_state.mask; + cursor.enable = par->cursor_state.enable; cursor.image.depth =1 ; cursor.rop =ROP_XOR ;
@@ -369,31 +369,31 @@ static void bit_cursor(struct vc_data *vc, struct fb_info *info, bool enable,if (err)soft_cursor (info, &cursor); - ops->cursor_reset =0 ; + par->cursor_reset =0 ; }static int bit_update_start (struct fb_info *info) { -struct fbcon_ops *ops = info->fbcon_par; +struct fbcon_par *par = info->fbcon_par;int err; - err =fb_pan_display (info, &ops->var); - ops->var.xoffset = info->var.xoffset; - ops->var.yoffset = info->var.yoffset; - ops->var.vmode = info->var.vmode; + err =fb_pan_display (info, &par->var); + par->var.xoffset = info->var.xoffset; + par->var.yoffset = info->var.yoffset; + par->var.vmode = info->var.vmode;return err; } -void fbcon_set_bitops (struct fbcon_ops *ops) +void fbcon_set_bitops (struct fbcon_par *par) { - ops->bmove = bit_bmove; - ops->clear = bit_clear; - ops->putcs = bit_putcs; - ops->clear_margins = bit_clear_margins; - ops->cursor = bit_cursor; - ops->update_start = bit_update_start; - ops->rotate_font =NULL ; - -if (ops->rotate) -fbcon_set_rotate (ops); + par->bmove = bit_bmove; + par->clear = bit_clear; + par->putcs = bit_putcs; + par->clear_margins = bit_clear_margins; + par->cursor = bit_cursor; + par->update_start = bit_update_start; + par->rotate_font =NULL ; + +if (par->rotate) +fbcon_set_rotate (par); }
drivers/video/fbdev/core/fbcon.c +204 -215
1,061 lines not on this page · raw message
drivers/video/fbdev/core/fbcon.h +3 -3
@@ -51,7 +51,7 @@ struct fbcon_display {const struct fb_videomode *mode; }; -struct fbcon_ops { +struct fbcon_par {void (*bmove)(struct vc_data *vc,struct fb_info *info,int sy,int sx,int dy,int dx,int height,int width); void (*clear)(struct vc_data *vc, struct fb_info *info, int sy,
@@ -186,7 +186,7 @@ static inline u_short fb_scrollmode(struct fbcon_display *fb)#ifdef CONFIG_FB_TILEBLITTING extern void fbcon_set_tileops (struct vc_data *vc,struct fb_info *info);#endif -extern void fbcon_set_bitops (struct fbcon_ops *ops); +extern void fbcon_set_bitops (struct fbcon_par *par);extern int soft_cursor (struct fb_info *info,struct fb_cursor *cursor);#define FBCON_ATTRIBUTE_UNDERLINE 1
@@ -225,7 +225,7 @@ static inline int get_attribute(struct fb_info *info, u16 c) (i == FB_ROTATE_UR || i == FB_ROTATE_UD) ? _r : _v; })#ifdef CONFIG_FRAMEBUFFER_CONSOLE_ROTATION -extern void fbcon_set_rotate (struct fbcon_ops *ops); +extern void fbcon_set_rotate (struct fbcon_par *par);#else #define fbcon_set_rotate (x) do {} while(0)#endif /* CONFIG_FRAMEBUFFER_CONSOLE_ROTATION */
drivers/video/fbdev/core/fbcon_ccw.c +73 -73
261 lines not on this page · raw message
drivers/video/fbdev/core/fbcon_cw.c +73 -73
261 lines not on this page · raw message
drivers/video/fbdev/core/fbcon_rotate.c +20 -20
@@ -20,32 +20,32 @@static int fbcon_rotate_font (struct fb_info *info,struct vc_data *vc) { -struct fbcon_ops *ops = info->fbcon_par; +struct fbcon_par *par = info->fbcon_par;int len, err =0 ;int s_cellsize, d_cellsize, i;const u8 *src;u8 *dst; -if (vc->vc_font.data == ops->fontdata && - ops->p->con_rotate == ops->cur_rotate) +if (vc->vc_font.data == par->fontdata && + par->p->con_rotate == par->cur_rotate) goto finished; - src = ops->fontdata = vc->vc_font.data; - ops->cur_rotate = ops->p->con_rotate; + src = par->fontdata = vc->vc_font.data; + par->cur_rotate = par->p->con_rotate; len = vc->vc_font.charcount; s_cellsize = ((vc->vc_font.width +7 )/8 ) * vc->vc_font.height; d_cellsize = s_cellsize; -if (ops->rotate ==FB_ROTATE_CW || - ops->rotate ==FB_ROTATE_CCW ) +if (par->rotate ==FB_ROTATE_CW || + par->rotate ==FB_ROTATE_CCW ) d_cellsize = ((vc->vc_font.height +7 )/8 ) * vc->vc_font.width;if (info->fbops->fb_sync) info->fbops->fb_sync (info); -if (ops->fd_size < d_cellsize * len) { +if (par->fd_size < d_cellsize * len) { dst =kmalloc_array (len, d_cellsize,GFP_KERNEL );if (dst ==NULL ) {
@@ -53,15 +53,15 @@ static int fbcon_rotate_font(struct fb_info *info, struct vc_data *vc) goto finished; } - ops->fd_size = d_cellsize * len; -kfree (ops->fontbuffer); - ops->fontbuffer = dst; + par->fd_size = d_cellsize * len; +kfree (par->fontbuffer); + par->fontbuffer = dst; } - dst = ops->fontbuffer; -memset (dst,0 , ops->fd_size); + dst = par->fontbuffer; +memset (dst,0 , par->fd_size); -switch (ops->rotate) { +switch (par->rotate) {case FB_ROTATE_UD :for (i = len; i--; ) { rotate_ud(src, dst, vc->vc_font.width,
@@ -93,19 +93,19 @@ static int fbcon_rotate_font(struct fb_info *info, struct vc_data *vc)return err; } -void fbcon_set_rotate (struct fbcon_ops *ops) +void fbcon_set_rotate (struct fbcon_par *par) { - ops->rotate_font = fbcon_rotate_font; + par->rotate_font = fbcon_rotate_font; -switch (ops->rotate) { +switch (par->rotate) {case FB_ROTATE_CW : -fbcon_rotate_cw (ops); +fbcon_rotate_cw (par);break ;case FB_ROTATE_UD : -fbcon_rotate_ud (ops); +fbcon_rotate_ud (par);break ;case FB_ROTATE_CCW : -fbcon_rotate_ccw (ops); +fbcon_rotate_ccw (par);break ; } }
drivers/video/fbdev/core/fbcon_rotate.h +3 -3
@@ -90,7 +90,7 @@ static inline void rotate_ccw(const char *in, char *out, u32 width, u32 height) } } -extern void fbcon_rotate_cw (struct fbcon_ops *ops); -extern void fbcon_rotate_ud (struct fbcon_ops *ops); -extern void fbcon_rotate_ccw (struct fbcon_ops *ops); +extern void fbcon_rotate_cw (struct fbcon_par *par); +extern void fbcon_rotate_ud (struct fbcon_par *par); +extern void fbcon_rotate_ccw (struct fbcon_par *par);#endif
drivers/video/fbdev/core/fbcon_ud.c +81 -81
291 lines not on this page · raw message
drivers/video/fbdev/core/softcursor.c +9 -9
@@ -21,7 +21,7 @@int soft_cursor (struct fb_info *info,struct fb_cursor *cursor) { -struct fbcon_ops *ops = info->fbcon_par; +struct fbcon_par *par = info->fbcon_par;unsigned int scan_align = info->pixmap.scan_align -1 ;unsigned int buf_align = info->pixmap.buf_align -1 ;unsigned int i, size, dsize, s_pitch, d_pitch;
@@ -34,19 +34,19 @@ int soft_cursor(struct fb_info *info, struct fb_cursor *cursor) s_pitch = (cursor->image.width +7 ) >>3 ; dsize = s_pitch * cursor->image.height; -if (dsize +sizeof (struct fb_image ) != ops->cursor_size) { -kfree (ops->cursor_src); - ops->cursor_size = dsize +sizeof (struct fb_image ); +if (dsize +sizeof (struct fb_image ) != par->cursor_size) { +kfree (par->cursor_src); + par->cursor_size = dsize +sizeof (struct fb_image ); - ops->cursor_src =kmalloc (ops->cursor_size,GFP_ATOMIC ); -if (!ops->cursor_src) { - ops->cursor_size =0 ; + par->cursor_src =kmalloc (par->cursor_size,GFP_ATOMIC ); +if (!par->cursor_src) { + par->cursor_size =0 ;return -ENOMEM ; } } - src = ops->cursor_src +sizeof (struct fb_image ); - image = (struct fb_image *)ops->cursor_src; + src = par->cursor_src +sizeof (struct fb_image ); + image = (struct fb_image *)par->cursor_src; *image = cursor->image; d_pitch = (s_pitch + scan_align) & ~scan_align;
drivers/video/fbdev/core/tileblit.c +14 -14
@@ -151,34 +151,34 @@ static void tile_cursor(struct vc_data *vc, struct fb_info *info, bool enable,static int tile_update_start (struct fb_info *info) { -struct fbcon_ops *ops = info->fbcon_par; +struct fbcon_par *par = info->fbcon_par;int err; - err =fb_pan_display (info, &ops->var); - ops->var.xoffset = info->var.xoffset; - ops->var.yoffset = info->var.yoffset; - ops->var.vmode = info->var.vmode; + err =fb_pan_display (info, &par->var); + par->var.xoffset = info->var.xoffset; + par->var.yoffset = info->var.yoffset; + par->var.vmode = info->var.vmode;return err; }void fbcon_set_tileops (struct vc_data *vc,struct fb_info *info) {struct fb_tilemap map; -struct fbcon_ops *ops = info->fbcon_par; +struct fbcon_par *par = info->fbcon_par; - ops->bmove = tile_bmove; - ops->clear = tile_clear; - ops->putcs = tile_putcs; - ops->clear_margins = tile_clear_margins; - ops->cursor = tile_cursor; - ops->update_start = tile_update_start; + par->bmove = tile_bmove; + par->clear = tile_clear; + par->putcs = tile_putcs; + par->clear_margins = tile_clear_margins; + par->cursor = tile_cursor; + par->update_start = tile_update_start; -if (ops->p) { +if (par->p) { map.width = vc->vc_font.width; map.height = vc->vc_font.height; map.depth =1 ; map.length = vc->vc_font.charcount; - map.data = ops->p->fontdata; + map.data = par->p->fontdata; info->tileops->fb_settile (info, &map); } }
Signature · 1 line
2.51.0
Thomas Zimmermann
maintainerPATCH v2 3/5 fbcon: Set rotate_font callback with related callbacks
In reply to Thomas ZimmermannThe field struct fbcon_par.rotate_font points to fbcon_rotate_font() if the console is rotated. Set the callback in the same place as the other callbacks. Prepares for declaring all fbcon callbacks in a dedicated struct type.
If not rotated, fbcon_set_bitops() still clears the callback to NULL.
--- drivers/video/fbdev/core/fbcon_ccw.c | 1 + drivers/video/fbdev/core/fbcon_cw.c | 1 + drivers/video/fbdev/core/fbcon_rotate.c | 4 +--- drivers/video/fbdev/core/fbcon_rotate.h | 3 +++ drivers/video/fbdev/core/fbcon_ud.c | 1 + 5 files changed, 7 insertions(+), 3 deletions(-)
drivers/video/fbdev/core/fbcon_ccw.c +1 -0
@@ -398,4 +398,5 @@ void fbcon_rotate_ccw(struct fbcon_par *par) par->clear_margins = ccw_clear_margins; par->cursor = ccw_cursor; par->update_start = ccw_update_start; + par->rotate_font = fbcon_rotate_font; }
drivers/video/fbdev/core/fbcon_cw.c +1 -0
@@ -381,4 +381,5 @@ void fbcon_rotate_cw(struct fbcon_par *par) par->clear_margins = cw_clear_margins; par->cursor = cw_cursor; par->update_start = cw_update_start; + par->rotate_font = fbcon_rotate_font; }
drivers/video/fbdev/core/fbcon_rotate.c +1 -3
@@ -18,7 +18,7 @@#include "fbcon.h" #include "fbcon_rotate.h" -static int fbcon_rotate_font (struct fb_info *info,struct vc_data *vc) +int fbcon_rotate_font (struct fb_info *info,struct vc_data *vc) {struct fbcon_par *par = info->fbcon_par;int len, err =0 ;
@@ -95,8 +95,6 @@ static int fbcon_rotate_font(struct fb_info *info, struct vc_data *vc)void fbcon_set_rotate (struct fbcon_par *par) { - par->rotate_font = fbcon_rotate_font; -switch (par->rotate) {case FB_ROTATE_CW :fbcon_rotate_cw (par);
drivers/video/fbdev/core/fbcon_rotate.h +3 -0
@@ -90,7 +90,10 @@ static inline void rotate_ccw(const char *in, char *out, u32 width, u32 height) } } +int fbcon_rotate_font (struct fb_info *info,struct vc_data *vc); +extern void fbcon_rotate_cw (struct fbcon_par *par);extern void fbcon_rotate_ud (struct fbcon_par *par);extern void fbcon_rotate_ccw (struct fbcon_par *par); +#endif
drivers/video/fbdev/core/fbcon_ud.c +1 -0
@@ -425,4 +425,5 @@ void fbcon_rotate_ud(struct fbcon_par *par) par->clear_margins = ud_clear_margins; par->cursor = ud_cursor; par->update_start = ud_update_start; + par->rotate_font = fbcon_rotate_font; }
Signature · 1 line
2.51.0
Thomas Zimmermann
maintainerPATCH v2 4/5 fbcon: Move fbcon callbacks into struct fbcon_bitops
In reply to Thomas ZimmermannDepending on rotation settings, fbcon sets different callback functions in struct fbcon_par from within fbcon_set_bitops(). Declare the callback functions in the new type struct fbcon_bitops. Then only replace the single bitops pointer in struct fbcon_par.
Keeping callbacks in constant instances of struct fbcon_bitops makes it harder to exploit the callbacks. Also makes the code slightly easier to maintain.
For tile-based consoles, there's a separate instance of the bitops structure.
--- drivers/video/fbdev/core/bitblit.c | 17 ++++--- drivers/video/fbdev/core/fbcon.c | 67 +++++++++++++++------------- drivers/video/fbdev/core/fbcon.h | 7 ++- drivers/video/fbdev/core/fbcon_ccw.c | 18 +++++--- drivers/video/fbdev/core/fbcon_cw.c | 18 +++++--- drivers/video/fbdev/core/fbcon_ud.c | 18 +++++--- drivers/video/fbdev/core/tileblit.c | 16 ++++--- 7 files changed, 94 insertions(+), 67 deletions(-)
drivers/video/fbdev/core/bitblit.c +10 -7
@@ -384,15 +384,18 @@ static int bit_update_start(struct fb_info *info)return err; } +static const struct fbcon_bitops bit_fbcon_bitops = { + .bmove = bit_bmove, + .clear = bit_clear, + .putcs = bit_putcs, + .clear_margins = bit_clear_margins, + .cursor = bit_cursor, + .update_start = bit_update_start, +}; +void fbcon_set_bitops (struct fbcon_par *par) { - par->bmove = bit_bmove; - par->clear = bit_clear; - par->putcs = bit_putcs; - par->clear_margins = bit_clear_margins; - par->cursor = bit_cursor; - par->update_start = bit_update_start; - par->rotate_font =NULL ; + par->bitops = &bit_fbcon_bitops;if (par->rotate)fbcon_set_rotate (par);
drivers/video/fbdev/core/fbcon.c +35 -32
190 lines not on this page · raw message
drivers/video/fbdev/core/fbcon.h +6 -1
@@ -51,7 +51,7 @@ struct fbcon_display {const struct fb_videomode *mode; }; -struct fbcon_par { +struct fbcon_bitops {void (*bmove)(struct vc_data *vc,struct fb_info *info,int sy,int sx,int dy,int dx,int height,int width); void (*clear)(struct vc_data *vc, struct fb_info *info, int sy,
@@ -65,6 +65,9 @@ struct fbcon_par { bool enable, int fg, int bg);int (*update_start)(struct fb_info *info);int (*rotate_font)(struct fb_info *info,struct vc_data *vc); +}; + +struct fbcon_par {struct fb_var_screeninfo var;/* copy of the current fb_var_screeninfo */ struct delayed_work cursor_work;/* Cursor timer */ struct fb_cursor cursor_state;
@@ -86,6 +89,8 @@ struct fbcon_par {u8 *cursor_src;u32 cursor_size;u32 fd_size; + +const struct fbcon_bitops *bitops; };/*
drivers/video/fbdev/core/fbcon_ccw.c +11 -7
@@ -390,13 +390,17 @@ static int ccw_update_start(struct fb_info *info)return err; } +static const struct fbcon_bitops ccw_fbcon_bitops = { + .bmove = ccw_bmove, + .clear = ccw_clear, + .putcs = ccw_putcs, + .clear_margins = ccw_clear_margins, + .cursor = ccw_cursor, + .update_start = ccw_update_start, + .rotate_font = fbcon_rotate_font, +}; +void fbcon_rotate_ccw (struct fbcon_par *par) { - par->bmove = ccw_bmove; - par->clear = ccw_clear; - par->putcs = ccw_putcs; - par->clear_margins = ccw_clear_margins; - par->cursor = ccw_cursor; - par->update_start = ccw_update_start; - par->rotate_font = fbcon_rotate_font; + par->bitops = &ccw_fbcon_bitops; }
drivers/video/fbdev/core/fbcon_cw.c +11 -7
@@ -373,13 +373,17 @@ static int cw_update_start(struct fb_info *info)return err; } +static const struct fbcon_bitops cw_fbcon_bitops = { + .bmove = cw_bmove, + .clear = cw_clear, + .putcs = cw_putcs, + .clear_margins = cw_clear_margins, + .cursor = cw_cursor, + .update_start = cw_update_start, + .rotate_font = fbcon_rotate_font, +}; +void fbcon_rotate_cw (struct fbcon_par *par) { - par->bmove = cw_bmove; - par->clear = cw_clear; - par->putcs = cw_putcs; - par->clear_margins = cw_clear_margins; - par->cursor = cw_cursor; - par->update_start = cw_update_start; - par->rotate_font = fbcon_rotate_font; + par->bitops = &cw_fbcon_bitops; }
drivers/video/fbdev/core/fbcon_ud.c +11 -7
@@ -417,13 +417,17 @@ static int ud_update_start(struct fb_info *info)return err; } +static const struct fbcon_bitops ud_fbcon_bitops = { + .bmove = ud_bmove, + .clear = ud_clear, + .putcs = ud_putcs, + .clear_margins = ud_clear_margins, + .cursor = ud_cursor, + .update_start = ud_update_start, + .rotate_font = fbcon_rotate_font, +}; +void fbcon_rotate_ud (struct fbcon_par *par) { - par->bmove = ud_bmove; - par->clear = ud_clear; - par->putcs = ud_putcs; - par->clear_margins = ud_clear_margins; - par->cursor = ud_cursor; - par->update_start = ud_update_start; - par->rotate_font = fbcon_rotate_font; + par->bitops = &ud_fbcon_bitops; }
drivers/video/fbdev/core/tileblit.c +10 -6
@@ -161,17 +161,21 @@ static int tile_update_start(struct fb_info *info)return err; } +static const struct fbcon_bitops tile_fbcon_bitops = { + .bmove = tile_bmove, + .clear = tile_clear, + .putcs = tile_putcs, + .clear_margins = tile_clear_margins, + .cursor = tile_cursor, + .update_start = tile_update_start, +}; +void fbcon_set_tileops (struct vc_data *vc,struct fb_info *info) {struct fb_tilemap map;struct fbcon_par *par = info->fbcon_par; - par->bmove = tile_bmove; - par->clear = tile_clear; - par->putcs = tile_putcs; - par->clear_margins = tile_clear_margins; - par->cursor = tile_cursor; - par->update_start = tile_update_start; + par->bitops = &tile_fbcon_bitops;if (par->p) { map.width = vc->vc_font.width;
Signature · 1 line
2.51.0
Thomas Zimmermann
maintainerPATCH v2 5/5 fbcon: Streamline setting rotated/unrotated bitops
In reply to Thomas ZimmermannSupport for console rotation is somewhat bolted onto the helper fbcon_set_bitops() for unrotated displays.
Update fbcon_set_bitops() with a switch statement that picks the correct settings helper for the current rotation. For unrotated consoles, set the bitops for in the new helper fbcon_set_bitops_ur(). Rename the other, existing helpers to match the common naming scheme.
The old helper fbcon_set_rotate() is no longer used.
--- drivers/video/fbdev/core/bitblit.c | 5 +---- drivers/video/fbdev/core/fbcon.c | 21 +++++++++++++++++++++ drivers/video/fbdev/core/fbcon.h | 8 +------- drivers/video/fbdev/core/fbcon_ccw.c | 2 +- drivers/video/fbdev/core/fbcon_cw.c | 2 +- drivers/video/fbdev/core/fbcon_rotate.c | 15 --------------- drivers/video/fbdev/core/fbcon_rotate.h | 15 ++++++++++++--- drivers/video/fbdev/core/fbcon_ud.c | 2 +- 8 files changed, 38 insertions(+), 32 deletions(-)
drivers/video/fbdev/core/bitblit.c +1 -4
@@ -393,10 +393,7 @@ static const struct fbcon_bitops bit_fbcon_bitops = { .update_start = bit_update_start, }; -void fbcon_set_bitops (struct fbcon_par *par) +void fbcon_set_bitops_ur (struct fbcon_par *par) { par->bitops = &bit_fbcon_bitops; - -if (par->rotate) -fbcon_set_rotate (par); }
drivers/video/fbdev/core/fbcon.c +21 -0
@@ -81,6 +81,7 @@#include <asm/irq.h> #include "fbcon.h" +#include "fbcon_rotate.h" #include "fb_internal.h" /*
@@ -270,6 +271,26 @@ static void fbcon_rotate_all(struct fb_info *info, u32 rotate) }#endif /* CONFIG_FRAMEBUFFER_CONSOLE_ROTATION */ +static void fbcon_set_bitops (struct fbcon_par *par) +{ +switch (par->rotate) { +default : + fallthrough; +case FB_ROTATE_UR : +fbcon_set_bitops_ur (par); +break ; +case FB_ROTATE_CW : +fbcon_set_bitops_cw (par); +break ; +case FB_ROTATE_UD : +fbcon_set_bitops_ud (par); +break ; +case FB_ROTATE_CCW : +fbcon_set_bitops_ccw (par); +break ; + } +} +static int fbcon_get_rotate (struct fb_info *info) {struct fbcon_par *par = info->fbcon_par;
drivers/video/fbdev/core/fbcon.h +1 -7
@@ -191,7 +191,7 @@ static inline u_short fb_scrollmode(struct fbcon_display *fb)#ifdef CONFIG_FB_TILEBLITTING extern void fbcon_set_tileops (struct vc_data *vc,struct fb_info *info);#endif -extern void fbcon_set_bitops (struct fbcon_par *par); +extern void fbcon_set_bitops_ur (struct fbcon_par *par);extern int soft_cursor (struct fb_info *info,struct fb_cursor *cursor);#define FBCON_ATTRIBUTE_UNDERLINE 1
@@ -229,10 +229,4 @@ static inline int get_attribute(struct fb_info *info, u16 c) (void ) (&_r == &_v); \ (i == FB_ROTATE_UR || i == FB_ROTATE_UD) ? _r : _v; }) -#ifdef CONFIG_FRAMEBUFFER_CONSOLE_ROTATION -extern void fbcon_set_rotate (struct fbcon_par *par); -#else -#define fbcon_set_rotate (x) do {} while(0) -#endif /* CONFIG_FRAMEBUFFER_CONSOLE_ROTATION */ -#endif /* _VIDEO_FBCON_H */
drivers/video/fbdev/core/fbcon_ccw.c +1 -1
@@ -400,7 +400,7 @@ static const struct fbcon_bitops ccw_fbcon_bitops = { .rotate_font = fbcon_rotate_font, }; -void fbcon_rotate_ccw (struct fbcon_par *par) +void fbcon_set_bitops_ccw (struct fbcon_par *par) { par->bitops = &ccw_fbcon_bitops; }
drivers/video/fbdev/core/fbcon_cw.c +1 -1
@@ -383,7 +383,7 @@ static const struct fbcon_bitops cw_fbcon_bitops = { .rotate_font = fbcon_rotate_font, }; -void fbcon_rotate_cw (struct fbcon_par *par) +void fbcon_set_bitops_cw (struct fbcon_par *par) { par->bitops = &cw_fbcon_bitops; }
drivers/video/fbdev/core/fbcon_rotate.c +0 -15
@@ -92,18 +92,3 @@ int fbcon_rotate_font(struct fb_info *info, struct vc_data *vc) finished:return err; } - -void fbcon_set_rotate (struct fbcon_par *par) -{ -switch (par->rotate) { -case FB_ROTATE_CW : -fbcon_rotate_cw (par); -break ; -case FB_ROTATE_UD : -fbcon_rotate_ud (par); -break ; -case FB_ROTATE_CCW : -fbcon_rotate_ccw (par); -break ; - } -}
drivers/video/fbdev/core/fbcon_rotate.h +12 -3
@@ -92,8 +92,17 @@ static inline void rotate_ccw(const char *in, char *out, u32 width, u32 height)int fbcon_rotate_font (struct fb_info *info,struct vc_data *vc); -extern void fbcon_rotate_cw (struct fbcon_par *par); -extern void fbcon_rotate_ud (struct fbcon_par *par); -extern void fbcon_rotate_ccw (struct fbcon_par *par); +#if defined(CONFIG_FRAMEBUFFER_CONSOLE_ROTATION ) +void fbcon_set_bitops_cw (struct fbcon_par *par); +void fbcon_set_bitops_ud (struct fbcon_par *par); +void fbcon_set_bitops_ccw (struct fbcon_par *par); +#else +static inline void fbcon_set_bitops_cw (struct fbcon_par *par) +{ } +static inline void fbcon_set_bitops_ud (struct fbcon_par *par) +{ } +static inline void fbcon_set_bitops_ccw (struct fbcon_par *par) +{ } +#endif #endif
drivers/video/fbdev/core/fbcon_ud.c +1 -1
@@ -427,7 +427,7 @@ static const struct fbcon_bitops ud_fbcon_bitops = { .rotate_font = fbcon_rotate_font, }; -void fbcon_rotate_ud (struct fbcon_par *par) +void fbcon_set_bitops_ud (struct fbcon_par *par) { par->bitops = &ud_fbcon_bitops; }
Signature · 1 line
2.51.0