diff options
author | Russell King <rmk+kernel@arm.linux.org.uk> | 2010-03-08 20:21:04 +0000 |
---|---|---|
committer | Russell King <rmk+kernel@arm.linux.org.uk> | 2010-03-08 20:21:04 +0000 |
commit | 988addf82e4c03739375279de73929580a2d4a6a (patch) | |
tree | 989ae1cd4e264bbad80c65f04480486246e7b9f3 /drivers/video/omap2/omapfb | |
parent | 004c1c7096659d352b83047a7593e91d8a30e3c5 (diff) | |
parent | 25cf84cf377c0aae5dbcf937ea89bc7893db5176 (diff) |
Merge branch 'origin' into devel-stable
Conflicts:
arch/arm/mach-mx2/devices.c
arch/arm/mach-mx2/devices.h
sound/soc/pxa/pxa-ssp.c
Diffstat (limited to 'drivers/video/omap2/omapfb')
-rw-r--r-- | drivers/video/omap2/omapfb/Kconfig | 11 | ||||
-rw-r--r-- | drivers/video/omap2/omapfb/omapfb-ioctl.c | 68 | ||||
-rw-r--r-- | drivers/video/omap2/omapfb/omapfb-main.c | 133 | ||||
-rw-r--r-- | drivers/video/omap2/omapfb/omapfb.h | 9 |
4 files changed, 135 insertions, 86 deletions
diff --git a/drivers/video/omap2/omapfb/Kconfig b/drivers/video/omap2/omapfb/Kconfig index bb694cc52a5..43496d6c377 100644 --- a/drivers/video/omap2/omapfb/Kconfig +++ b/drivers/video/omap2/omapfb/Kconfig @@ -16,16 +16,7 @@ config FB_OMAP2_DEBUG_SUPPORT depends on FB_OMAP2 help Support for debug output. You have to enable the actual printing - with debug module parameter. - -config FB_OMAP2_FORCE_AUTO_UPDATE - bool "Force main display to automatic update mode" - depends on FB_OMAP2 - help - Forces main display to automatic update mode (if possible), - and also enables tearsync (if possible). By default - displays that support manual update are started in manual - update mode. + with 'debug' module parameter. config FB_OMAP2_NUM_FBS int "Number of framebuffers" diff --git a/drivers/video/omap2/omapfb/omapfb-ioctl.c b/drivers/video/omap2/omapfb/omapfb-ioctl.c index 4c4bafdfaa4..1ffa760b854 100644 --- a/drivers/video/omap2/omapfb/omapfb-ioctl.c +++ b/drivers/video/omap2/omapfb/omapfb-ioctl.c @@ -167,12 +167,12 @@ static int omapfb_update_window_nolock(struct fb_info *fbi, if (w == 0 || h == 0) return 0; - display->get_resolution(display, &dw, &dh); + display->driver->get_resolution(display, &dw, &dh); if (x + w > dw || y + h > dh) return -EINVAL; - return display->update(display, x, y, w, h); + return display->driver->update(display, x, y, w, h); } /* This function is exported for SGX driver use */ @@ -202,7 +202,7 @@ static int omapfb_set_update_mode(struct fb_info *fbi, enum omap_dss_update_mode um; int r; - if (!display || !display->set_update_mode) + if (!display || !display->driver->set_update_mode) return -EINVAL; switch (mode) { @@ -222,7 +222,7 @@ static int omapfb_set_update_mode(struct fb_info *fbi, return -EINVAL; } - r = display->set_update_mode(display, um); + r = display->driver->set_update_mode(display, um); return r; } @@ -233,10 +233,15 @@ static int omapfb_get_update_mode(struct fb_info *fbi, struct omap_dss_device *display = fb2display(fbi); enum omap_dss_update_mode m; - if (!display || !display->get_update_mode) + if (!display) return -EINVAL; - m = display->get_update_mode(display); + if (!display->driver->get_update_mode) { + *mode = OMAPFB_AUTO_UPDATE; + return 0; + } + + m = display->driver->get_update_mode(display); switch (m) { case OMAP_DSS_UPDATE_DISABLED: @@ -374,7 +379,7 @@ static int omapfb_memory_read(struct fb_info *fbi, void *buf; int r; - if (!display || !display->memory_read) + if (!display || !display->driver->memory_read) return -ENOENT; if (!access_ok(VERIFY_WRITE, mr->buffer, mr->buffer_size)) @@ -389,7 +394,7 @@ static int omapfb_memory_read(struct fb_info *fbi, return -ENOMEM; } - r = display->memory_read(display, buf, mr->buffer_size, + r = display->driver->memory_read(display, buf, mr->buffer_size, mr->x, mr->y, mr->w, mr->h); if (r > 0) { @@ -483,6 +488,7 @@ int omapfb_ioctl(struct fb_info *fbi, unsigned int cmd, unsigned long arg) struct omapfb_memory_read memory_read; struct omapfb_vram_info vram_info; struct omapfb_tearsync_info tearsync_info; + struct omapfb_display_info display_info; } p; int r = 0; @@ -490,18 +496,18 @@ int omapfb_ioctl(struct fb_info *fbi, unsigned int cmd, unsigned long arg) switch (cmd) { case OMAPFB_SYNC_GFX: DBG("ioctl SYNC_GFX\n"); - if (!display || !display->sync) { + if (!display || !display->driver->sync) { /* DSS1 never returns an error here, so we neither */ /*r = -EINVAL;*/ break; } - r = display->sync(display); + r = display->driver->sync(display); break; case OMAPFB_UPDATE_WINDOW_OLD: DBG("ioctl UPDATE_WINDOW_OLD\n"); - if (!display || !display->update) { + if (!display || !display->driver->update) { r = -EINVAL; break; } @@ -519,7 +525,7 @@ int omapfb_ioctl(struct fb_info *fbi, unsigned int cmd, unsigned long arg) case OMAPFB_UPDATE_WINDOW: DBG("ioctl UPDATE_WINDOW\n"); - if (!display || !display->update) { + if (!display || !display->driver->update) { r = -EINVAL; break; } @@ -648,7 +654,7 @@ int omapfb_ioctl(struct fb_info *fbi, unsigned int cmd, unsigned long arg) break; } - r = display->wait_vsync(display); + r = display->manager->wait_for_vsync(display->manager); break; case OMAPFB_WAITFORGO: @@ -669,12 +675,12 @@ int omapfb_ioctl(struct fb_info *fbi, unsigned int cmd, unsigned long arg) r = -EFAULT; break; } - if (!display || !display->run_test) { + if (!display || !display->driver->run_test) { r = -EINVAL; break; } - r = display->run_test(display, p.test_num); + r = display->driver->run_test(display, p.test_num); break; @@ -684,12 +690,12 @@ int omapfb_ioctl(struct fb_info *fbi, unsigned int cmd, unsigned long arg) r = -EFAULT; break; } - if (!display || !display->run_test) { + if (!display || !display->driver->run_test) { r = -EINVAL; break; } - r = display->run_test(display, p.test_num); + r = display->driver->run_test(display, p.test_num); break; @@ -731,13 +737,37 @@ int omapfb_ioctl(struct fb_info *fbi, unsigned int cmd, unsigned long arg) break; } - if (!display->enable_te) { + if (!display->driver->enable_te) { r = -ENODEV; break; } - r = display->enable_te(display, !!p.tearsync_info.enabled); + r = display->driver->enable_te(display, + !!p.tearsync_info.enabled); + + break; + } + + case OMAPFB_GET_DISPLAY_INFO: { + u16 xres, yres; + DBG("ioctl GET_DISPLAY_INFO\n"); + + if (display == NULL) { + r = -ENODEV; + break; + } + + display->driver->get_resolution(display, &xres, &yres); + + p.display_info.xres = xres; + p.display_info.yres = yres; + p.display_info.width = 0; + p.display_info.height = 0; + + if (copy_to_user((void __user *)arg, &p.display_info, + sizeof(p.display_info))) + r = -EFAULT; break; } diff --git a/drivers/video/omap2/omapfb/omapfb-main.c b/drivers/video/omap2/omapfb/omapfb-main.c index d17caef6915..4a76917b7cc 100644 --- a/drivers/video/omap2/omapfb/omapfb-main.c +++ b/drivers/video/omap2/omapfb/omapfb-main.c @@ -54,6 +54,8 @@ module_param_named(test, omapfb_test_pattern, bool, 0644); #endif static int omapfb_fb_init(struct omapfb2_device *fbdev, struct fb_info *fbi); +static int omapfb_get_recommended_bpp(struct omapfb2_device *fbdev, + struct omap_dss_device *dssdev); #ifdef DEBUG static void draw_pixel(struct fb_info *fbi, int x, int y, unsigned color) @@ -152,9 +154,9 @@ static void fill_fb(struct fb_info *fbi) } #endif -static unsigned omapfb_get_vrfb_offset(struct omapfb_info *ofbi, int rot) +static unsigned omapfb_get_vrfb_offset(const struct omapfb_info *ofbi, int rot) { - struct vrfb *vrfb = &ofbi->region.vrfb; + const struct vrfb *vrfb = &ofbi->region.vrfb; unsigned offset; switch (rot) { @@ -179,7 +181,7 @@ static unsigned omapfb_get_vrfb_offset(struct omapfb_info *ofbi, int rot) return offset; } -static u32 omapfb_get_region_rot_paddr(struct omapfb_info *ofbi, int rot) +static u32 omapfb_get_region_rot_paddr(const struct omapfb_info *ofbi, int rot) { if (ofbi->rotation_type == OMAP_DSS_ROT_VRFB) { return ofbi->region.vrfb.paddr[rot] @@ -189,7 +191,7 @@ static u32 omapfb_get_region_rot_paddr(struct omapfb_info *ofbi, int rot) } } -static u32 omapfb_get_region_paddr(struct omapfb_info *ofbi) +static u32 omapfb_get_region_paddr(const struct omapfb_info *ofbi) { if (ofbi->rotation_type == OMAP_DSS_ROT_VRFB) return ofbi->region.vrfb.paddr[0]; @@ -197,7 +199,7 @@ static u32 omapfb_get_region_paddr(struct omapfb_info *ofbi) return ofbi->region.paddr; } -static void __iomem *omapfb_get_region_vaddr(struct omapfb_info *ofbi) +static void __iomem *omapfb_get_region_vaddr(const struct omapfb_info *ofbi) { if (ofbi->rotation_type == OMAP_DSS_ROT_VRFB) return ofbi->region.vrfb.vaddr[0]; @@ -703,9 +705,9 @@ int check_fb_var(struct fb_info *fbi, struct fb_var_screeninfo *var) var->width = -1; var->grayscale = 0; - if (display && display->get_timings) { + if (display && display->driver->get_timings) { struct omap_video_timings timings; - display->get_timings(display, &timings); + display->driver->get_timings(display, &timings); /* pixclock in ps, the rest in pixclock */ var->pixclock = timings.pixel_clock != 0 ? @@ -778,8 +780,8 @@ static int omapfb_release(struct fb_info *fbi, int user) return 0; } -static unsigned calc_rotation_offset_dma(struct fb_var_screeninfo *var, - struct fb_fix_screeninfo *fix, int rotation) +static unsigned calc_rotation_offset_dma(const struct fb_var_screeninfo *var, + const struct fb_fix_screeninfo *fix, int rotation) { unsigned offset; @@ -789,8 +791,8 @@ static unsigned calc_rotation_offset_dma(struct fb_var_screeninfo *var, return offset; } -static unsigned calc_rotation_offset_vrfb(struct fb_var_screeninfo *var, - struct fb_fix_screeninfo *fix, int rotation) +static unsigned calc_rotation_offset_vrfb(const struct fb_var_screeninfo *var, + const struct fb_fix_screeninfo *fix, int rotation) { unsigned offset; @@ -1221,11 +1223,11 @@ static int omapfb_blank(int blank, struct fb_info *fbi) if (display->state != OMAP_DSS_DISPLAY_SUSPENDED) goto exit; - if (display->resume) - r = display->resume(display); + if (display->driver->resume) + r = display->driver->resume(display); - if (r == 0 && display->get_update_mode && - display->get_update_mode(display) == + if (r == 0 && display->driver->get_update_mode && + display->driver->get_update_mode(display) == OMAP_DSS_UPDATE_MANUAL) do_update = 1; @@ -1240,8 +1242,8 @@ static int omapfb_blank(int blank, struct fb_info *fbi) if (display->state != OMAP_DSS_DISPLAY_ACTIVE) goto exit; - if (display->suspend) - r = display->suspend(display); + if (display->driver->suspend) + r = display->driver->suspend(display); break; @@ -1252,11 +1254,11 @@ static int omapfb_blank(int blank, struct fb_info *fbi) exit: omapfb_unlock(fbdev); - if (r == 0 && do_update && display->update) { + if (r == 0 && do_update && display->driver->update) { u16 w, h; - display->get_resolution(display, &w, &h); + display->driver->get_resolution(display, &w, &h); - r = display->update(display, 0, 0, w, h); + r = display->driver->update(display, 0, 0, w, h); } return r; @@ -1404,6 +1406,7 @@ static int omapfb_alloc_fbmem_display(struct fb_info *fbi, unsigned long size, unsigned long paddr) { struct omapfb_info *ofbi = FB2OFB(fbi); + struct omapfb2_device *fbdev = ofbi->fbdev; struct omap_dss_device *display; int bytespp; @@ -1412,7 +1415,7 @@ static int omapfb_alloc_fbmem_display(struct fb_info *fbi, unsigned long size, if (!display) return 0; - switch (display->get_recommended_bpp(display)) { + switch (omapfb_get_recommended_bpp(fbdev, display)) { case 16: bytespp = 2; break; @@ -1427,7 +1430,7 @@ static int omapfb_alloc_fbmem_display(struct fb_info *fbi, unsigned long size, if (!size) { u16 w, h; - display->get_resolution(display, &w, &h); + display->driver->get_resolution(display, &w, &h); if (ofbi->rotation_type == OMAP_DSS_ROT_VRFB) { size = max(omap_vrfb_min_phys_size(w, h, bytespp), @@ -1636,8 +1639,8 @@ int omapfb_realloc_fbmem(struct fb_info *fbi, unsigned long size, int type) if (old_size == size && old_type == type) return 0; - if (display && display->sync) - display->sync(display); + if (display && display->driver->sync) + display->driver->sync(display); omapfb_free_fbmem(fbi); @@ -1745,7 +1748,7 @@ static int omapfb_fb_init(struct omapfb2_device *fbdev, struct fb_info *fbi) u16 w, h; int rotation = (var->rotate + ofbi->rotation[0]) % 4; - display->get_resolution(display, &w, &h); + display->driver->get_resolution(display, &w, &h); if (rotation == FB_ROTATE_CW || rotation == FB_ROTATE_CCW) { @@ -1760,7 +1763,7 @@ static int omapfb_fb_init(struct omapfb2_device *fbdev, struct fb_info *fbi) var->yres_virtual = var->yres; if (!var->bits_per_pixel) { - switch (display->get_recommended_bpp(display)) { + switch (omapfb_get_recommended_bpp(fbdev, display)) { case 16: var->bits_per_pixel = 16; break; @@ -1828,7 +1831,7 @@ static void omapfb_free_resources(struct omapfb2_device *fbdev) for (i = 0; i < fbdev->num_displays; i++) { if (fbdev->displays[i]->state != OMAP_DSS_DISPLAY_DISABLED) - fbdev->displays[i]->disable(fbdev->displays[i]); + fbdev->displays[i]->driver->disable(fbdev->displays[i]); omap_dss_put_device(fbdev->displays[i]); } @@ -2011,7 +2014,8 @@ static int omapfb_mode_to_timings(const char *mode_str, } } -static int omapfb_set_def_mode(struct omap_dss_device *display, char *mode_str) +static int omapfb_set_def_mode(struct omapfb2_device *fbdev, + struct omap_dss_device *display, char *mode_str) { int r; u8 bpp; @@ -2021,20 +2025,37 @@ static int omapfb_set_def_mode(struct omap_dss_device *display, char *mode_str) if (r) return r; - display->panel.recommended_bpp = bpp; + fbdev->bpp_overrides[fbdev->num_bpp_overrides].dssdev = display; + fbdev->bpp_overrides[fbdev->num_bpp_overrides].bpp = bpp; + ++fbdev->num_bpp_overrides; - if (!display->check_timings || !display->set_timings) + if (!display->driver->check_timings || !display->driver->set_timings) return -EINVAL; - r = display->check_timings(display, &timings); + r = display->driver->check_timings(display, &timings); if (r) return r; - display->set_timings(display, &timings); + display->driver->set_timings(display, &timings); return 0; } +static int omapfb_get_recommended_bpp(struct omapfb2_device *fbdev, + struct omap_dss_device *dssdev) +{ + int i; + + BUG_ON(dssdev->driver->get_recommended_bpp == NULL); + + for (i = 0; i < fbdev->num_bpp_overrides; ++i) { + if (dssdev == fbdev->bpp_overrides[i].dssdev) + return fbdev->bpp_overrides[i].bpp; + } + + return dssdev->driver->get_recommended_bpp(dssdev); +} + static int omapfb_parse_def_modes(struct omapfb2_device *fbdev) { char *str, *options, *this_opt; @@ -2073,7 +2094,7 @@ static int omapfb_parse_def_modes(struct omapfb2_device *fbdev) break; } - r = omapfb_set_def_mode(display, mode_str); + r = omapfb_set_def_mode(fbdev, display, mode_str); if (r) break; } @@ -2111,18 +2132,23 @@ static int omapfb_probe(struct platform_device *pdev) fbdev->dev = &pdev->dev; platform_set_drvdata(pdev, fbdev); + r = 0; fbdev->num_displays = 0; dssdev = NULL; for_each_dss_dev(dssdev) { omap_dss_get_device(dssdev); + if (!dssdev->driver) { dev_err(&pdev->dev, "no driver for display\n"); - r = -EINVAL; - goto cleanup; + r = -ENODEV; } + fbdev->displays[fbdev->num_displays++] = dssdev; } + if (r) + goto cleanup; + if (fbdev->num_displays == 0) { dev_err(&pdev->dev, "no displays\n"); r = -EINVAL; @@ -2167,35 +2193,28 @@ static int omapfb_probe(struct platform_device *pdev) } if (def_display) { -#ifndef CONFIG_FB_OMAP2_FORCE_AUTO_UPDATE - u16 w, h; -#endif - r = def_display->enable(def_display); - if (r) + struct omap_dss_driver *dssdrv = def_display->driver; + + r = def_display->driver->enable(def_display); + if (r) { dev_warn(fbdev->dev, "Failed to enable display '%s'\n", def_display->name); + goto cleanup; + } - /* set the update mode */ if (def_display->caps & OMAP_DSS_DISPLAY_CAP_MANUAL_UPDATE) { -#ifdef CONFIG_FB_OMAP2_FORCE_AUTO_UPDATE - if (def_display->enable_te) - def_display->enable_te(def_display, 1); - if (def_display->set_update_mode) - def_display->set_update_mode(def_display, - OMAP_DSS_UPDATE_AUTO); -#else /* MANUAL_UPDATE */ - if (def_display->enable_te) - def_display->enable_te(def_display, 0); - if (def_display->set_update_mode) - def_display->set_update_mode(def_display, + u16 w, h; + if (dssdrv->enable_te) + dssdrv->enable_te(def_display, 1); + if (dssdrv->set_update_mode) + dssdrv->set_update_mode(def_display, OMAP_DSS_UPDATE_MANUAL); - def_display->get_resolution(def_display, &w, &h); - def_display->update(def_display, 0, 0, w, h); -#endif + dssdrv->get_resolution(def_display, &w, &h); + def_display->driver->update(def_display, 0, 0, w, h); } else { - if (def_display->set_update_mode) - def_display->set_update_mode(def_display, + if (dssdrv->set_update_mode) + dssdrv->set_update_mode(def_display, OMAP_DSS_UPDATE_AUTO); } } diff --git a/drivers/video/omap2/omapfb/omapfb.h b/drivers/video/omap2/omapfb/omapfb.h index f7c9c739e5e..cd54fdbfd8b 100644 --- a/drivers/video/omap2/omapfb/omapfb.h +++ b/drivers/video/omap2/omapfb/omapfb.h @@ -83,6 +83,12 @@ struct omapfb2_device { struct omap_overlay *overlays[10]; unsigned num_managers; struct omap_overlay_manager *managers[10]; + + unsigned num_bpp_overrides; + struct { + struct omap_dss_device *dssdev; + u8 bpp; + } bpp_overrides[10]; }; struct omapfb_colormode { @@ -105,6 +111,9 @@ void omapfb_remove_sysfs(struct omapfb2_device *fbdev); int omapfb_ioctl(struct fb_info *fbi, unsigned int cmd, unsigned long arg); +int omapfb_update_window(struct fb_info *fbi, + u32 x, u32 y, u32 w, u32 h); + int dss_mode_to_fb_mode(enum omap_color_mode dssmode, struct fb_var_screeninfo *var); |