diff options
author | Laurent Pinchart <laurent.pinchart@ideasonboard.com> | 2011-11-29 07:42:48 -0500 |
---|---|---|
committer | Laurent Pinchart <laurent.pinchart@ideasonboard.com> | 2012-03-12 17:40:54 -0400 |
commit | 2d04559dc23bed905ed2904f2bbcbcc3f1a7fd91 (patch) | |
tree | 7ef55431faa1dd60d332aff9cfac0cec5676e967 | |
parent | 13f80eea562be6cd58b5bdefc224c87cc0d9288d (diff) |
fbdev: sh_mobile_lcdc: Store display mode in a struct fb_videomode
Embed struct fb_videomode instead of struct fb_var_screeninfo in struct
sh_mobile_lcdc_chan to store the display mode.
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
-rw-r--r-- | drivers/video/sh_mobile_lcdcfb.c | 74 | ||||
-rw-r--r-- | drivers/video/sh_mobile_lcdcfb.h | 6 |
2 files changed, 44 insertions, 36 deletions
diff --git a/drivers/video/sh_mobile_lcdcfb.c b/drivers/video/sh_mobile_lcdcfb.c index 986346dbe05d..422fcfd3cf28 100644 --- a/drivers/video/sh_mobile_lcdcfb.c +++ b/drivers/video/sh_mobile_lcdcfb.c | |||
@@ -368,21 +368,17 @@ static bool | |||
368 | sh_mobile_lcdc_must_reconfigure(struct sh_mobile_lcdc_chan *ch, | 368 | sh_mobile_lcdc_must_reconfigure(struct sh_mobile_lcdc_chan *ch, |
369 | const struct fb_videomode *new_mode) | 369 | const struct fb_videomode *new_mode) |
370 | { | 370 | { |
371 | struct fb_var_screeninfo *old_var = &ch->display_var; | ||
372 | struct fb_videomode old_mode; | ||
373 | |||
374 | fb_var_to_videomode(&old_mode, old_var); | ||
375 | |||
376 | dev_dbg(ch->info->dev, "Old %ux%u, new %ux%u\n", | 371 | dev_dbg(ch->info->dev, "Old %ux%u, new %ux%u\n", |
377 | old_mode.xres, old_mode.yres, new_mode->xres, new_mode->yres); | 372 | ch->display.mode.xres, ch->display.mode.yres, |
373 | new_mode->xres, new_mode->yres); | ||
378 | 374 | ||
379 | /* It can be a different monitor with an equal video-mode */ | 375 | /* It can be a different monitor with an equal video-mode */ |
380 | if (fb_mode_is_equal(&old_mode, new_mode)) | 376 | if (fb_mode_is_equal(&ch->display.mode, new_mode)) |
381 | return false; | 377 | return false; |
382 | 378 | ||
383 | dev_dbg(ch->info->dev, "Switching %u -> %u lines\n", | 379 | dev_dbg(ch->info->dev, "Switching %u -> %u lines\n", |
384 | old_mode.yres, new_mode->yres); | 380 | ch->display.mode.yres, new_mode->yres); |
385 | fb_videomode_to_var(old_var, new_mode); | 381 | ch->display.mode = *new_mode; |
386 | 382 | ||
387 | return true; | 383 | return true; |
388 | } | 384 | } |
@@ -405,8 +401,8 @@ static int sh_mobile_lcdc_display_notify(struct sh_mobile_lcdc_chan *ch, | |||
405 | if (lock_fb_info(info)) { | 401 | if (lock_fb_info(info)) { |
406 | console_lock(); | 402 | console_lock(); |
407 | 403 | ||
408 | ch->display_var.width = monspec->max_x * 10; | 404 | ch->display.width = monspec->max_x * 10; |
409 | ch->display_var.height = monspec->max_y * 10; | 405 | ch->display.height = monspec->max_y * 10; |
410 | 406 | ||
411 | if (!sh_mobile_lcdc_must_reconfigure(ch, mode) && | 407 | if (!sh_mobile_lcdc_must_reconfigure(ch, mode) && |
412 | info->state == FBINFO_STATE_RUNNING) { | 408 | info->state == FBINFO_STATE_RUNNING) { |
@@ -569,7 +565,8 @@ static void sh_mobile_lcdc_start_stop(struct sh_mobile_lcdc_priv *priv, | |||
569 | 565 | ||
570 | static void sh_mobile_lcdc_geometry(struct sh_mobile_lcdc_chan *ch) | 566 | static void sh_mobile_lcdc_geometry(struct sh_mobile_lcdc_chan *ch) |
571 | { | 567 | { |
572 | struct fb_var_screeninfo *var = &ch->info->var, *display_var = &ch->display_var; | 568 | const struct fb_var_screeninfo *var = &ch->info->var; |
569 | const struct fb_videomode *mode = &ch->display.mode; | ||
573 | unsigned long h_total, hsync_pos, display_h_total; | 570 | unsigned long h_total, hsync_pos, display_h_total; |
574 | u32 tmp; | 571 | u32 tmp; |
575 | 572 | ||
@@ -588,34 +585,32 @@ static void sh_mobile_lcdc_geometry(struct sh_mobile_lcdc_chan *ch) | |||
588 | lcdc_write_chan(ch, LDMT3R, ch->cfg.sys_bus_cfg.ldmt3r); | 585 | lcdc_write_chan(ch, LDMT3R, ch->cfg.sys_bus_cfg.ldmt3r); |
589 | 586 | ||
590 | /* horizontal configuration */ | 587 | /* horizontal configuration */ |
591 | h_total = display_var->xres + display_var->hsync_len + | 588 | h_total = mode->xres + mode->hsync_len + mode->left_margin |
592 | display_var->left_margin + display_var->right_margin; | 589 | + mode->right_margin; |
593 | tmp = h_total / 8; /* HTCN */ | 590 | tmp = h_total / 8; /* HTCN */ |
594 | tmp |= (min(display_var->xres, var->xres) / 8) << 16; /* HDCN */ | 591 | tmp |= (min(mode->xres, var->xres) / 8) << 16; /* HDCN */ |
595 | lcdc_write_chan(ch, LDHCNR, tmp); | 592 | lcdc_write_chan(ch, LDHCNR, tmp); |
596 | 593 | ||
597 | hsync_pos = display_var->xres + display_var->right_margin; | 594 | hsync_pos = mode->xres + mode->right_margin; |
598 | tmp = hsync_pos / 8; /* HSYNP */ | 595 | tmp = hsync_pos / 8; /* HSYNP */ |
599 | tmp |= (display_var->hsync_len / 8) << 16; /* HSYNW */ | 596 | tmp |= (mode->hsync_len / 8) << 16; /* HSYNW */ |
600 | lcdc_write_chan(ch, LDHSYNR, tmp); | 597 | lcdc_write_chan(ch, LDHSYNR, tmp); |
601 | 598 | ||
602 | /* vertical configuration */ | 599 | /* vertical configuration */ |
603 | tmp = display_var->yres + display_var->vsync_len + | 600 | tmp = mode->yres + mode->vsync_len + mode->upper_margin |
604 | display_var->upper_margin + display_var->lower_margin; /* VTLN */ | 601 | + mode->lower_margin; /* VTLN */ |
605 | tmp |= min(display_var->yres, var->yres) << 16; /* VDLN */ | 602 | tmp |= min(mode->yres, var->yres) << 16; /* VDLN */ |
606 | lcdc_write_chan(ch, LDVLNR, tmp); | 603 | lcdc_write_chan(ch, LDVLNR, tmp); |
607 | 604 | ||
608 | tmp = display_var->yres + display_var->lower_margin; /* VSYNP */ | 605 | tmp = mode->yres + mode->lower_margin; /* VSYNP */ |
609 | tmp |= display_var->vsync_len << 16; /* VSYNW */ | 606 | tmp |= mode->vsync_len << 16; /* VSYNW */ |
610 | lcdc_write_chan(ch, LDVSYNR, tmp); | 607 | lcdc_write_chan(ch, LDVSYNR, tmp); |
611 | 608 | ||
612 | /* Adjust horizontal synchronisation for HDMI */ | 609 | /* Adjust horizontal synchronisation for HDMI */ |
613 | display_h_total = display_var->xres + display_var->hsync_len + | 610 | display_h_total = mode->xres + mode->hsync_len + mode->left_margin |
614 | display_var->left_margin + display_var->right_margin; | 611 | + mode->right_margin; |
615 | tmp = ((display_var->xres & 7) << 24) | | 612 | tmp = ((mode->xres & 7) << 24) | ((display_h_total & 7) << 16) |
616 | ((display_h_total & 7) << 16) | | 613 | | ((mode->hsync_len & 7) << 8) | (hsync_pos & 7); |
617 | ((display_var->hsync_len & 7) << 8) | | ||
618 | (hsync_pos & 7); | ||
619 | lcdc_write_chan(ch, LDHAJR, tmp); | 614 | lcdc_write_chan(ch, LDHAJR, tmp); |
620 | } | 615 | } |
621 | 616 | ||
@@ -1106,7 +1101,8 @@ static int sh_mobile_ioctl(struct fb_info *info, unsigned int cmd, | |||
1106 | static void sh_mobile_fb_reconfig(struct fb_info *info) | 1101 | static void sh_mobile_fb_reconfig(struct fb_info *info) |
1107 | { | 1102 | { |
1108 | struct sh_mobile_lcdc_chan *ch = info->par; | 1103 | struct sh_mobile_lcdc_chan *ch = info->par; |
1109 | struct fb_videomode mode1, mode2; | 1104 | struct fb_var_screeninfo var; |
1105 | struct fb_videomode mode; | ||
1110 | struct fb_event event; | 1106 | struct fb_event event; |
1111 | int evnt = FB_EVENT_MODE_CHANGE_ALL; | 1107 | int evnt = FB_EVENT_MODE_CHANGE_ALL; |
1112 | 1108 | ||
@@ -1114,14 +1110,19 @@ static void sh_mobile_fb_reconfig(struct fb_info *info) | |||
1114 | /* More framebuffer users are active */ | 1110 | /* More framebuffer users are active */ |
1115 | return; | 1111 | return; |
1116 | 1112 | ||
1117 | fb_var_to_videomode(&mode1, &ch->display_var); | 1113 | fb_var_to_videomode(&mode, &info->var); |
1118 | fb_var_to_videomode(&mode2, &info->var); | ||
1119 | 1114 | ||
1120 | if (fb_mode_is_equal(&mode1, &mode2)) | 1115 | if (fb_mode_is_equal(&ch->display.mode, &mode)) |
1121 | return; | 1116 | return; |
1122 | 1117 | ||
1123 | /* Display has been re-plugged, framebuffer is free now, reconfigure */ | 1118 | /* Display has been re-plugged, framebuffer is free now, reconfigure */ |
1124 | if (fb_set_var(info, &ch->display_var) < 0) | 1119 | var = info->var; |
1120 | fb_videomode_to_var(&var, &ch->display.mode); | ||
1121 | var.width = ch->display.width; | ||
1122 | var.height = ch->display.height; | ||
1123 | var.activate = FB_ACTIVATE_NOW; | ||
1124 | |||
1125 | if (fb_set_var(info, &var) < 0) | ||
1125 | /* Couldn't reconfigure, hopefully, can continue as before */ | 1126 | /* Couldn't reconfigure, hopefully, can continue as before */ |
1126 | return; | 1127 | return; |
1127 | 1128 | ||
@@ -1131,7 +1132,7 @@ static void sh_mobile_fb_reconfig(struct fb_info *info) | |||
1131 | * user event, we have to call the chain ourselves. | 1132 | * user event, we have to call the chain ourselves. |
1132 | */ | 1133 | */ |
1133 | event.info = info; | 1134 | event.info = info; |
1134 | event.data = &mode1; | 1135 | event.data = &ch->display.mode; |
1135 | fb_notifier_call_chain(evnt, &event); | 1136 | fb_notifier_call_chain(evnt, &event); |
1136 | } | 1137 | } |
1137 | 1138 | ||
@@ -1815,7 +1816,10 @@ sh_mobile_lcdc_channel_init(struct sh_mobile_lcdc_priv *priv, | |||
1815 | 1816 | ||
1816 | info->screen_base = buf; | 1817 | info->screen_base = buf; |
1817 | info->device = priv->dev; | 1818 | info->device = priv->dev; |
1818 | ch->display_var = *var; | 1819 | |
1820 | ch->display.width = cfg->panel_cfg.width; | ||
1821 | ch->display.height = cfg->panel_cfg.height; | ||
1822 | ch->display.mode = *mode; | ||
1819 | 1823 | ||
1820 | return 0; | 1824 | return 0; |
1821 | } | 1825 | } |
diff --git a/drivers/video/sh_mobile_lcdcfb.h b/drivers/video/sh_mobile_lcdcfb.h index 9c91fae1ea45..c1753877b4ec 100644 --- a/drivers/video/sh_mobile_lcdcfb.h +++ b/drivers/video/sh_mobile_lcdcfb.h | |||
@@ -68,7 +68,11 @@ struct sh_mobile_lcdc_chan { | |||
68 | unsigned long pan_offset; | 68 | unsigned long pan_offset; |
69 | wait_queue_head_t frame_end_wait; | 69 | wait_queue_head_t frame_end_wait; |
70 | struct completion vsync_completion; | 70 | struct completion vsync_completion; |
71 | struct fb_var_screeninfo display_var; | 71 | struct { |
72 | unsigned int width; | ||
73 | unsigned int height; | ||
74 | struct fb_videomode mode; | ||
75 | } display; | ||
72 | int use_count; | 76 | int use_count; |
73 | int blank_status; | 77 | int blank_status; |
74 | struct mutex open_lock; /* protects the use counter */ | 78 | struct mutex open_lock; /* protects the use counter */ |