Merge branch 'exynos-drm-next' of git://git.kernel.org/pub/scm/linux/kernel/git/daeinki/drm-exynos into drm-next

Summary:
- Consider fallback option to gem allocation fail
. try to allocate physically non-contiguous memory
if iommu is supported when physically contiguous memory allocation
failed.
- Add runtime pm support to g2d driver
- Add device tree support
. add device tree support to rotator driver, make fimd driver get
signal polarities from device tree.
- some fixups
. correct pixel format setting to fimd driver, and consider pixel
format checking to a particular window layer.
- some cleanups
. replace fb_videomode with videomode.
. remove non-DT support

* 'exynos-drm-next' of git://git.kernel.org/pub/scm/linux/kernel/git/daeinki/drm-exynos: (21 commits)
drm/exynos: Fix build error with exynos_drm_connector.c
drm/exynos: Remove non-DT support in exynos_drm_fimd
drm/exynos: Remove non-DT support in exynos_hdmi
drm/exynos: Remove non-DT support in exynos_drm_g2d
drm/exynos: Remove non-DT support in exynos_hdmiphy
drm/exynos: Remove non-DT support in exynos_ddc
drm/exynos: Make Exynos DRM drivers depend on OF
drm/exynos: Consider fallback option to allocation fail
drm/exynos: fimd: move platform data parsing to separate function
drm/exynos: fimd: get signal polarities from device tree
drm/exynos: fimd: replace struct fb_videomode with videomode
drm/exynos: check a pixel format to a particular window layer
drm/exynos: fix fimd pixel format setting
drm/exynos: Add NULL pointer check
drm/exynos: Remove redundant error messages
drm/exynos: Add missing of.h header include
drm/exynos: Remove redundant NULL check in exynos_drm_buf
drm/exynos: add device tree support for rotator
drm/exynos: Add missing includes
drm/exynos: add runtime pm interfaces to g2d driver
...

+358 -400
+27
Documentation/devicetree/bindings/gpu/samsung-rotator.txt
··· 1 + * Samsung Image Rotator 2 + 3 + Required properties: 4 + - compatible : value should be one of the following: 5 + (a) "samsung,exynos4210-rotator" for Rotator IP in Exynos4210 6 + (b) "samsung,exynos4212-rotator" for Rotator IP in Exynos4212/4412 7 + (c) "samsung,exynos5250-rotator" for Rotator IP in Exynos5250 8 + 9 + - reg : Physical base address of the IP registers and length of memory 10 + mapped region. 11 + 12 + - interrupts : Interrupt specifier for rotator interrupt, according to format 13 + specific to interrupt parent. 14 + 15 + - clocks : Clock specifier for rotator clock, according to generic clock 16 + bindings. (See Documentation/devicetree/bindings/clock/exynos*.txt) 17 + 18 + - clock-names : Names of clocks. For exynos rotator, it should be "rotator". 19 + 20 + Example: 21 + rotator@12810000 { 22 + compatible = "samsung,exynos4210-rotator"; 23 + reg = <0x12810000 0x1000>; 24 + interrupts = <0 83 0>; 25 + clocks = <&clock 278>; 26 + clock-names = "rotator"; 27 + };
+3 -3
drivers/gpu/drm/exynos/Kconfig
··· 1 1 config DRM_EXYNOS 2 2 tristate "DRM Support for Samsung SoC EXYNOS Series" 3 - depends on DRM && (PLAT_SAMSUNG || ARCH_MULTIPLATFORM) 3 + depends on OF && DRM && (PLAT_SAMSUNG || ARCH_MULTIPLATFORM) 4 4 select DRM_KMS_HELPER 5 5 select FB_CFB_FILLRECT 6 6 select FB_CFB_COPYAREA 7 7 select FB_CFB_IMAGEBLIT 8 8 select VT_HW_CONSOLE_BINDING if FRAMEBUFFER_CONSOLE 9 + select VIDEOMODE_HELPERS 9 10 help 10 11 Choose this option if you have a Samsung SoC EXYNOS chipset. 11 12 If M is selected the module will be called exynosdrm. ··· 25 24 26 25 config DRM_EXYNOS_FIMD 27 26 bool "Exynos DRM FIMD" 28 - depends on OF && DRM_EXYNOS && !FB_S3C && !ARCH_MULTIPLATFORM 27 + depends on DRM_EXYNOS && !FB_S3C && !ARCH_MULTIPLATFORM 29 28 select FB_MODE_HELPERS 30 - select VIDEOMODE_HELPERS 31 29 help 32 30 Choose this option if you want to use Exynos FIMD for DRM. 33 31
+2 -11
drivers/gpu/drm/exynos/exynos_ddc.c
··· 15 15 16 16 #include <linux/kernel.h> 17 17 #include <linux/i2c.h> 18 - 18 + #include <linux/of.h> 19 19 20 20 #include "exynos_drm_drv.h" 21 21 #include "exynos_hdmi.h" ··· 41 41 return 0; 42 42 } 43 43 44 - static struct i2c_device_id ddc_idtable[] = { 45 - {"s5p_ddc", 0}, 46 - {"exynos5-hdmiddc", 0}, 47 - { }, 48 - }; 49 - 50 - #ifdef CONFIG_OF 51 44 static struct of_device_id hdmiddc_match_types[] = { 52 45 { 53 46 .compatible = "samsung,exynos5-hdmiddc", ··· 50 57 /* end node */ 51 58 } 52 59 }; 53 - #endif 54 60 55 61 struct i2c_driver ddc_driver = { 56 62 .driver = { 57 63 .name = "exynos-hdmiddc", 58 64 .owner = THIS_MODULE, 59 - .of_match_table = of_match_ptr(hdmiddc_match_types), 65 + .of_match_table = hdmiddc_match_types, 60 66 }, 61 - .id_table = ddc_idtable, 62 67 .probe = s5p_ddc_probe, 63 68 .remove = s5p_ddc_remove, 64 69 .command = NULL,
+1 -8
drivers/gpu/drm/exynos/exynos_drm_buf.c
··· 149 149 DRM_DEBUG_KMS("desired size = 0x%x\n", size); 150 150 151 151 buffer = kzalloc(sizeof(*buffer), GFP_KERNEL); 152 - if (!buffer) { 153 - DRM_ERROR("failed to allocate exynos_drm_gem_buf.\n"); 152 + if (!buffer) 154 153 return NULL; 155 - } 156 154 157 155 buffer->size = size; 158 156 return buffer; ··· 159 161 void exynos_drm_fini_buf(struct drm_device *dev, 160 162 struct exynos_drm_gem_buf *buffer) 161 163 { 162 - if (!buffer) { 163 - DRM_DEBUG_KMS("buffer is null.\n"); 164 - return; 165 - } 166 - 167 164 kfree(buffer); 168 165 buffer = NULL; 169 166 }
+5 -33
drivers/gpu/drm/exynos/exynos_drm_connector.c
··· 17 17 #include <drm/exynos_drm.h> 18 18 #include "exynos_drm_drv.h" 19 19 #include "exynos_drm_encoder.h" 20 + #include "exynos_drm_connector.h" 20 21 21 22 #define to_exynos_connector(x) container_of(x, struct exynos_drm_connector,\ 22 23 drm_connector) ··· 28 27 struct exynos_drm_manager *manager; 29 28 uint32_t dpms; 30 29 }; 31 - 32 - /* convert exynos_video_timings to drm_display_mode */ 33 - static inline void 34 - convert_to_display_mode(struct drm_display_mode *mode, 35 - struct exynos_drm_panel_info *panel) 36 - { 37 - struct fb_videomode *timing = &panel->timing; 38 - 39 - mode->clock = timing->pixclock / 1000; 40 - mode->vrefresh = timing->refresh; 41 - 42 - mode->hdisplay = timing->xres; 43 - mode->hsync_start = mode->hdisplay + timing->right_margin; 44 - mode->hsync_end = mode->hsync_start + timing->hsync_len; 45 - mode->htotal = mode->hsync_end + timing->left_margin; 46 - 47 - mode->vdisplay = timing->yres; 48 - mode->vsync_start = mode->vdisplay + timing->lower_margin; 49 - mode->vsync_end = mode->vsync_start + timing->vsync_len; 50 - mode->vtotal = mode->vsync_end + timing->upper_margin; 51 - mode->width_mm = panel->width_mm; 52 - mode->height_mm = panel->height_mm; 53 - 54 - if (timing->vmode & FB_VMODE_INTERLACED) 55 - mode->flags |= DRM_MODE_FLAG_INTERLACE; 56 - 57 - if (timing->vmode & FB_VMODE_DOUBLE) 58 - mode->flags |= DRM_MODE_FLAG_DBLSCAN; 59 - } 60 30 61 31 static int exynos_drm_connector_get_modes(struct drm_connector *connector) 62 32 { ··· 83 111 return 0; 84 112 } 85 113 86 - convert_to_display_mode(mode, panel); 114 + drm_display_mode_from_videomode(&panel->vm, mode); 115 + mode->width_mm = panel->width_mm; 116 + mode->height_mm = panel->height_mm; 87 117 connector->display_info.width_mm = mode->width_mm; 88 118 connector->display_info.height_mm = mode->height_mm; 89 119 ··· 252 278 int err; 253 279 254 280 exynos_connector = kzalloc(sizeof(*exynos_connector), GFP_KERNEL); 255 - if (!exynos_connector) { 256 - DRM_ERROR("failed to allocate connector\n"); 281 + if (!exynos_connector) 257 282 return NULL; 258 - } 259 283 260 284 connector = &exynos_connector->drm_connector; 261 285
+2 -3
drivers/gpu/drm/exynos/exynos_drm_crtc.c
··· 15 15 #include <drm/drmP.h> 16 16 #include <drm/drm_crtc_helper.h> 17 17 18 + #include "exynos_drm_crtc.h" 18 19 #include "exynos_drm_drv.h" 19 20 #include "exynos_drm_encoder.h" 20 21 #include "exynos_drm_plane.h" ··· 325 324 struct drm_crtc *crtc; 326 325 327 326 exynos_crtc = kzalloc(sizeof(*exynos_crtc), GFP_KERNEL); 328 - if (!exynos_crtc) { 329 - DRM_ERROR("failed to allocate exynos crtc\n"); 327 + if (!exynos_crtc) 330 328 return -ENOMEM; 331 - } 332 329 333 330 exynos_crtc->pipe = nr; 334 331 exynos_crtc->dpms = DRM_MODE_DPMS_OFF;
+1 -1
drivers/gpu/drm/exynos/exynos_drm_dmabuf.c
··· 11 11 12 12 #include <drm/drmP.h> 13 13 #include <drm/exynos_drm.h> 14 + #include "exynos_drm_dmabuf.h" 14 15 #include "exynos_drm_drv.h" 15 16 #include "exynos_drm_gem.h" 16 17 ··· 231 230 232 231 buffer = kzalloc(sizeof(*buffer), GFP_KERNEL); 233 232 if (!buffer) { 234 - DRM_ERROR("failed to allocate exynos_drm_gem_buf.\n"); 235 233 ret = -ENOMEM; 236 234 goto err_unmap_attach; 237 235 }
+1 -3
drivers/gpu/drm/exynos/exynos_drm_drv.c
··· 47 47 int nr; 48 48 49 49 private = kzalloc(sizeof(struct exynos_drm_private), GFP_KERNEL); 50 - if (!private) { 51 - DRM_ERROR("failed to allocate private\n"); 50 + if (!private) 52 51 return -ENOMEM; 53 - } 54 52 55 53 INIT_LIST_HEAD(&private->pageflip_event_list); 56 54 dev->dev_private = (void *)private;
+1 -3
drivers/gpu/drm/exynos/exynos_drm_encoder.c
··· 324 324 return NULL; 325 325 326 326 exynos_encoder = kzalloc(sizeof(*exynos_encoder), GFP_KERNEL); 327 - if (!exynos_encoder) { 328 - DRM_ERROR("failed to allocate encoder\n"); 327 + if (!exynos_encoder) 329 328 return NULL; 330 - } 331 329 332 330 exynos_encoder->dpms = DRM_MODE_DPMS_OFF; 333 331 exynos_encoder->manager = manager;
+2 -6
drivers/gpu/drm/exynos/exynos_drm_fb.c
··· 156 156 } 157 157 158 158 exynos_fb = kzalloc(sizeof(*exynos_fb), GFP_KERNEL); 159 - if (!exynos_fb) { 160 - DRM_ERROR("failed to allocate exynos drm framebuffer\n"); 159 + if (!exynos_fb) 161 160 return ERR_PTR(-ENOMEM); 162 - } 163 161 164 162 drm_helper_mode_fill_fb_struct(&exynos_fb->fb, mode_cmd); 165 163 exynos_fb->exynos_gem_obj[0] = exynos_gem_obj; ··· 218 220 int i, ret; 219 221 220 222 exynos_fb = kzalloc(sizeof(*exynos_fb), GFP_KERNEL); 221 - if (!exynos_fb) { 222 - DRM_ERROR("failed to allocate exynos drm framebuffer\n"); 223 + if (!exynos_fb) 223 224 return ERR_PTR(-ENOMEM); 224 - } 225 225 226 226 obj = drm_gem_object_lookup(dev, file_priv, mode_cmd->handles[0]); 227 227 if (!obj) {
+15 -5
drivers/gpu/drm/exynos/exynos_drm_fbdev.c
··· 16 16 #include <drm/drm_crtc.h> 17 17 #include <drm/drm_fb_helper.h> 18 18 #include <drm/drm_crtc_helper.h> 19 + #include <drm/exynos_drm.h> 19 20 20 21 #include "exynos_drm_drv.h" 21 22 #include "exynos_drm_fb.h" 23 + #include "exynos_drm_fbdev.h" 22 24 #include "exynos_drm_gem.h" 23 25 #include "exynos_drm_iommu.h" 24 26 ··· 167 165 168 166 size = mode_cmd.pitches[0] * mode_cmd.height; 169 167 170 - /* 0 means to allocate physically continuous memory */ 171 - exynos_gem_obj = exynos_drm_gem_create(dev, 0, size); 168 + exynos_gem_obj = exynos_drm_gem_create(dev, EXYNOS_BO_CONTIG, size); 169 + /* 170 + * If physically contiguous memory allocation fails and if IOMMU is 171 + * supported then try to get buffer from non physically contiguous 172 + * memory area. 173 + */ 174 + if (IS_ERR(exynos_gem_obj) && is_drm_iommu_supported(dev)) { 175 + dev_warn(&pdev->dev, "contiguous FB allocation failed, falling back to non-contiguous\n"); 176 + exynos_gem_obj = exynos_drm_gem_create(dev, EXYNOS_BO_NONCONTIG, 177 + size); 178 + } 179 + 172 180 if (IS_ERR(exynos_gem_obj)) { 173 181 ret = PTR_ERR(exynos_gem_obj); 174 182 goto err_release_framebuffer; ··· 248 236 return 0; 249 237 250 238 fbdev = kzalloc(sizeof(*fbdev), GFP_KERNEL); 251 - if (!fbdev) { 252 - DRM_ERROR("failed to allocate drm fbdev.\n"); 239 + if (!fbdev) 253 240 return -ENOMEM; 254 - } 255 241 256 242 private->fb_helper = helper = &fbdev->drm_fb_helper; 257 243 helper->funcs = &exynos_drm_fb_helper_funcs;
+3 -3
drivers/gpu/drm/exynos/exynos_drm_fimc.c
··· 17 17 #include <linux/regmap.h> 18 18 #include <linux/clk.h> 19 19 #include <linux/pm_runtime.h> 20 + #include <linux/of.h> 20 21 21 22 #include <drm/drmP.h> 22 23 #include <drm/exynos_drm.h> 23 24 #include "regs-fimc.h" 25 + #include "exynos_drm_drv.h" 24 26 #include "exynos_drm_ipp.h" 25 27 #include "exynos_drm_fimc.h" 26 28 ··· 1345 1343 struct drm_exynos_ipp_prop_list *prop_list; 1346 1344 1347 1345 prop_list = devm_kzalloc(ippdrv->dev, sizeof(*prop_list), GFP_KERNEL); 1348 - if (!prop_list) { 1349 - DRM_ERROR("failed to alloc property list.\n"); 1346 + if (!prop_list) 1350 1347 return -ENOMEM; 1351 - } 1352 1348 1353 1349 prop_list->version = 1; 1354 1350 prop_list->writeback = 1;
+120 -143
drivers/gpu/drm/exynos/exynos_drm_fimd.c
··· 16 16 #include <linux/kernel.h> 17 17 #include <linux/platform_device.h> 18 18 #include <linux/clk.h> 19 + #include <linux/of.h> 19 20 #include <linux/of_device.h> 20 21 #include <linux/pm_runtime.h> 21 22 22 23 #include <video/of_display_timing.h> 24 + #include <video/of_videomode.h> 23 25 #include <video/samsung_fimd.h> 24 26 #include <drm/exynos_drm.h> 25 27 ··· 36 34 * to a LCD Panel through Display Interfaces such as RGB or 37 35 * CPU Interface. 38 36 */ 37 + 38 + #define FIMD_DEFAULT_FRAMERATE 60 39 39 40 40 /* position control register for hardware window 0, 2 ~ 4.*/ 41 41 #define VIDOSD_A(win) (VIDOSD_BASE + 0x00 + (win) * 16) ··· 69 65 70 66 unsigned int has_shadowcon:1; 71 67 unsigned int has_clksel:1; 68 + unsigned int has_limited_fmt:1; 72 69 }; 73 70 74 71 static struct fimd_driver_data s3c64xx_fimd_driver_data = { 75 72 .timing_base = 0x0, 76 73 .has_clksel = 1, 74 + .has_limited_fmt = 1, 77 75 }; 78 76 79 77 static struct fimd_driver_data exynos4_fimd_driver_data = { ··· 96 90 unsigned int fb_width; 97 91 unsigned int fb_height; 98 92 unsigned int bpp; 93 + unsigned int pixel_format; 99 94 dma_addr_t dma_addr; 100 95 unsigned int buf_offsize; 101 96 unsigned int line_size; /* bytes */ ··· 122 115 wait_queue_head_t wait_vsync_queue; 123 116 atomic_t wait_vsync_event; 124 117 125 - struct exynos_drm_panel_info *panel; 118 + struct exynos_drm_panel_info panel; 126 119 struct fimd_driver_data *driver_data; 127 120 }; 128 121 129 - #ifdef CONFIG_OF 130 122 static const struct of_device_id fimd_driver_dt_match[] = { 131 123 { .compatible = "samsung,s3c6400-fimd", 132 124 .data = &s3c64xx_fimd_driver_data }, ··· 135 129 .data = &exynos5_fimd_driver_data }, 136 130 {}, 137 131 }; 138 - #endif 139 132 140 133 static inline struct fimd_driver_data *drm_fimd_get_driver_data( 141 134 struct platform_device *pdev) 142 135 { 143 - #ifdef CONFIG_OF 144 136 const struct of_device_id *of_id = 145 137 of_match_device(fimd_driver_dt_match, &pdev->dev); 146 138 147 - if (of_id) 148 - return (struct fimd_driver_data *)of_id->data; 149 - #endif 150 - 151 - return (struct fimd_driver_data *) 152 - platform_get_device_id(pdev)->driver_data; 139 + return (struct fimd_driver_data *)of_id->data; 153 140 } 154 141 155 142 static bool fimd_display_is_connected(struct device *dev) ··· 156 157 { 157 158 struct fimd_context *ctx = get_fimd_context(dev); 158 159 159 - return ctx->panel; 160 + return &ctx->panel; 160 161 } 161 162 162 163 static int fimd_check_mode(struct device *dev, struct drm_display_mode *mode) ··· 236 237 static void fimd_commit(struct device *dev) 237 238 { 238 239 struct fimd_context *ctx = get_fimd_context(dev); 239 - struct exynos_drm_panel_info *panel = ctx->panel; 240 - struct fb_videomode *timing = &panel->timing; 240 + struct exynos_drm_panel_info *panel = &ctx->panel; 241 + struct videomode *vm = &panel->vm; 241 242 struct fimd_driver_data *driver_data; 242 243 u32 val; 243 244 ··· 249 250 writel(ctx->vidcon1, ctx->regs + driver_data->timing_base + VIDCON1); 250 251 251 252 /* setup vertical timing values. */ 252 - val = VIDTCON0_VBPD(timing->upper_margin - 1) | 253 - VIDTCON0_VFPD(timing->lower_margin - 1) | 254 - VIDTCON0_VSPW(timing->vsync_len - 1); 253 + val = VIDTCON0_VBPD(vm->vback_porch - 1) | 254 + VIDTCON0_VFPD(vm->vfront_porch - 1) | 255 + VIDTCON0_VSPW(vm->vsync_len - 1); 255 256 writel(val, ctx->regs + driver_data->timing_base + VIDTCON0); 256 257 257 258 /* setup horizontal timing values. */ 258 - val = VIDTCON1_HBPD(timing->left_margin - 1) | 259 - VIDTCON1_HFPD(timing->right_margin - 1) | 260 - VIDTCON1_HSPW(timing->hsync_len - 1); 259 + val = VIDTCON1_HBPD(vm->hback_porch - 1) | 260 + VIDTCON1_HFPD(vm->hfront_porch - 1) | 261 + VIDTCON1_HSPW(vm->hsync_len - 1); 261 262 writel(val, ctx->regs + driver_data->timing_base + VIDTCON1); 262 263 263 264 /* setup horizontal and vertical display size. */ 264 - val = VIDTCON2_LINEVAL(timing->yres - 1) | 265 - VIDTCON2_HOZVAL(timing->xres - 1) | 266 - VIDTCON2_LINEVAL_E(timing->yres - 1) | 267 - VIDTCON2_HOZVAL_E(timing->xres - 1); 265 + val = VIDTCON2_LINEVAL(vm->vactive - 1) | 266 + VIDTCON2_HOZVAL(vm->hactive - 1) | 267 + VIDTCON2_LINEVAL_E(vm->vactive - 1) | 268 + VIDTCON2_HOZVAL_E(vm->hactive - 1); 268 269 writel(val, ctx->regs + driver_data->timing_base + VIDTCON2); 269 270 270 271 /* setup clock source, clock divider, enable dma. */ ··· 395 396 win_data->fb_height = overlay->fb_height; 396 397 win_data->dma_addr = overlay->dma_addr[0] + offset; 397 398 win_data->bpp = overlay->bpp; 399 + win_data->pixel_format = overlay->pixel_format; 398 400 win_data->buf_offsize = (overlay->fb_width - overlay->crtc_width) * 399 401 (overlay->bpp >> 3); 400 402 win_data->line_size = overlay->crtc_width * (overlay->bpp >> 3); ··· 417 417 418 418 val = WINCONx_ENWIN; 419 419 420 - switch (win_data->bpp) { 421 - case 1: 422 - val |= WINCON0_BPPMODE_1BPP; 423 - val |= WINCONx_BITSWP; 424 - val |= WINCONx_BURSTLEN_4WORD; 425 - break; 426 - case 2: 427 - val |= WINCON0_BPPMODE_2BPP; 428 - val |= WINCONx_BITSWP; 429 - val |= WINCONx_BURSTLEN_8WORD; 430 - break; 431 - case 4: 432 - val |= WINCON0_BPPMODE_4BPP; 433 - val |= WINCONx_BITSWP; 434 - val |= WINCONx_BURSTLEN_8WORD; 435 - break; 436 - case 8: 420 + /* 421 + * In case of s3c64xx, window 0 doesn't support alpha channel. 422 + * So the request format is ARGB8888 then change it to XRGB8888. 423 + */ 424 + if (ctx->driver_data->has_limited_fmt && !win) { 425 + if (win_data->pixel_format == DRM_FORMAT_ARGB8888) 426 + win_data->pixel_format = DRM_FORMAT_XRGB8888; 427 + } 428 + 429 + switch (win_data->pixel_format) { 430 + case DRM_FORMAT_C8: 437 431 val |= WINCON0_BPPMODE_8BPP_PALETTE; 438 432 val |= WINCONx_BURSTLEN_8WORD; 439 433 val |= WINCONx_BYTSWP; 440 434 break; 441 - case 16: 435 + case DRM_FORMAT_XRGB1555: 436 + val |= WINCON0_BPPMODE_16BPP_1555; 437 + val |= WINCONx_HAWSWP; 438 + val |= WINCONx_BURSTLEN_16WORD; 439 + break; 440 + case DRM_FORMAT_RGB565: 442 441 val |= WINCON0_BPPMODE_16BPP_565; 443 442 val |= WINCONx_HAWSWP; 444 443 val |= WINCONx_BURSTLEN_16WORD; 445 444 break; 446 - case 24: 445 + case DRM_FORMAT_XRGB8888: 447 446 val |= WINCON0_BPPMODE_24BPP_888; 448 447 val |= WINCONx_WSWP; 449 448 val |= WINCONx_BURSTLEN_16WORD; 450 449 break; 451 - case 32: 452 - val |= WINCON1_BPPMODE_28BPP_A4888 450 + case DRM_FORMAT_ARGB8888: 451 + val |= WINCON1_BPPMODE_25BPP_A1888 453 452 | WINCON1_BLD_PIX | WINCON1_ALPHA_SEL; 454 453 val |= WINCONx_WSWP; 455 454 val |= WINCONx_BURSTLEN_16WORD; ··· 745 746 drm_iommu_detach_device(drm_dev, dev); 746 747 } 747 748 748 - static int fimd_calc_clkdiv(struct fimd_context *ctx, 749 - struct fb_videomode *timing) 749 + static int fimd_configure_clocks(struct fimd_context *ctx, struct device *dev) 750 750 { 751 - unsigned long clk = clk_get_rate(ctx->lcd_clk); 752 - u32 retrace; 753 - u32 clkdiv; 754 - u32 best_framerate = 0; 755 - u32 framerate; 751 + struct videomode *vm = &ctx->panel.vm; 752 + unsigned long clk; 756 753 757 - retrace = timing->left_margin + timing->hsync_len + 758 - timing->right_margin + timing->xres; 759 - retrace *= timing->upper_margin + timing->vsync_len + 760 - timing->lower_margin + timing->yres; 761 - 762 - /* default framerate is 60Hz */ 763 - if (!timing->refresh) 764 - timing->refresh = 60; 765 - 766 - clk /= retrace; 767 - 768 - for (clkdiv = 1; clkdiv < 0x100; clkdiv++) { 769 - int tmp; 770 - 771 - /* get best framerate */ 772 - framerate = clk / clkdiv; 773 - tmp = timing->refresh - framerate; 774 - if (tmp < 0) { 775 - best_framerate = framerate; 776 - continue; 777 - } else { 778 - if (!best_framerate) 779 - best_framerate = framerate; 780 - else if (tmp < (best_framerate - framerate)) 781 - best_framerate = framerate; 782 - break; 783 - } 754 + ctx->bus_clk = devm_clk_get(dev, "fimd"); 755 + if (IS_ERR(ctx->bus_clk)) { 756 + dev_err(dev, "failed to get bus clock\n"); 757 + return PTR_ERR(ctx->bus_clk); 784 758 } 785 759 786 - return clkdiv; 760 + ctx->lcd_clk = devm_clk_get(dev, "sclk_fimd"); 761 + if (IS_ERR(ctx->lcd_clk)) { 762 + dev_err(dev, "failed to get lcd clock\n"); 763 + return PTR_ERR(ctx->lcd_clk); 764 + } 765 + 766 + clk = clk_get_rate(ctx->lcd_clk); 767 + if (clk == 0) { 768 + dev_err(dev, "error getting sclk_fimd clock rate\n"); 769 + return -EINVAL; 770 + } 771 + 772 + if (vm->pixelclock == 0) { 773 + unsigned long c; 774 + c = vm->hactive + vm->hback_porch + vm->hfront_porch + 775 + vm->hsync_len; 776 + c *= vm->vactive + vm->vback_porch + vm->vfront_porch + 777 + vm->vsync_len; 778 + vm->pixelclock = c * FIMD_DEFAULT_FRAMERATE; 779 + if (vm->pixelclock == 0) { 780 + dev_err(dev, "incorrect display timings\n"); 781 + return -EINVAL; 782 + } 783 + dev_warn(dev, "pixel clock recalculated to %luHz (%dHz frame rate)\n", 784 + vm->pixelclock, FIMD_DEFAULT_FRAMERATE); 785 + } 786 + ctx->clkdiv = DIV_ROUND_UP(clk, vm->pixelclock); 787 + if (ctx->clkdiv > 256) { 788 + dev_warn(dev, "calculated pixel clock divider too high (%u), lowered to 256\n", 789 + ctx->clkdiv); 790 + ctx->clkdiv = 256; 791 + } 792 + vm->pixelclock = clk / ctx->clkdiv; 793 + DRM_DEBUG_KMS("pixel clock = %lu, clkdiv = %d\n", vm->pixelclock, 794 + ctx->clkdiv); 795 + 796 + return 0; 787 797 } 788 798 789 799 static void fimd_clear_win(struct fimd_context *ctx, int win) ··· 884 876 return 0; 885 877 } 886 878 879 + static int fimd_get_platform_data(struct fimd_context *ctx, struct device *dev) 880 + { 881 + struct videomode *vm; 882 + int ret; 883 + 884 + vm = &ctx->panel.vm; 885 + ret = of_get_videomode(dev->of_node, vm, OF_USE_NATIVE_MODE); 886 + if (ret) { 887 + DRM_ERROR("failed: of_get_videomode() : %d\n", ret); 888 + return ret; 889 + } 890 + 891 + if (vm->flags & DISPLAY_FLAGS_VSYNC_LOW) 892 + ctx->vidcon1 |= VIDCON1_INV_VSYNC; 893 + if (vm->flags & DISPLAY_FLAGS_HSYNC_LOW) 894 + ctx->vidcon1 |= VIDCON1_INV_HSYNC; 895 + if (vm->flags & DISPLAY_FLAGS_DE_LOW) 896 + ctx->vidcon1 |= VIDCON1_INV_VDEN; 897 + if (vm->flags & DISPLAY_FLAGS_PIXDATA_NEGEDGE) 898 + ctx->vidcon1 |= VIDCON1_INV_VCLK; 899 + 900 + return 0; 901 + } 902 + 887 903 static int fimd_probe(struct platform_device *pdev) 888 904 { 889 905 struct device *dev = &pdev->dev; 890 906 struct fimd_context *ctx; 891 907 struct exynos_drm_subdrv *subdrv; 892 - struct exynos_drm_fimd_pdata *pdata; 893 - struct exynos_drm_panel_info *panel; 894 908 struct resource *res; 895 909 int win; 896 910 int ret = -EINVAL; 897 911 898 - if (dev->of_node) { 899 - pdata = devm_kzalloc(dev, sizeof(*pdata), GFP_KERNEL); 900 - if (!pdata) { 901 - DRM_ERROR("memory allocation for pdata failed\n"); 902 - return -ENOMEM; 903 - } 904 - 905 - ret = of_get_fb_videomode(dev->of_node, &pdata->panel.timing, 906 - OF_USE_NATIVE_MODE); 907 - if (ret) { 908 - DRM_ERROR("failed: of_get_fb_videomode() : %d\n", ret); 909 - return ret; 910 - } 911 - } else { 912 - pdata = dev->platform_data; 913 - if (!pdata) { 914 - DRM_ERROR("no platform data specified\n"); 915 - return -EINVAL; 916 - } 917 - } 918 - 919 - panel = &pdata->panel; 920 - if (!panel) { 921 - dev_err(dev, "panel is null.\n"); 922 - return -EINVAL; 923 - } 912 + if (!dev->of_node) 913 + return -ENODEV; 924 914 925 915 ctx = devm_kzalloc(dev, sizeof(*ctx), GFP_KERNEL); 926 916 if (!ctx) 927 917 return -ENOMEM; 928 918 929 - ctx->bus_clk = devm_clk_get(dev, "fimd"); 930 - if (IS_ERR(ctx->bus_clk)) { 931 - dev_err(dev, "failed to get bus clock\n"); 932 - return PTR_ERR(ctx->bus_clk); 933 - } 919 + ret = fimd_get_platform_data(ctx, dev); 920 + if (ret) 921 + return ret; 934 922 935 - ctx->lcd_clk = devm_clk_get(dev, "sclk_fimd"); 936 - if (IS_ERR(ctx->lcd_clk)) { 937 - dev_err(dev, "failed to get lcd clock\n"); 938 - return PTR_ERR(ctx->lcd_clk); 939 - } 923 + ret = fimd_configure_clocks(ctx, dev); 924 + if (ret) 925 + return ret; 940 926 941 927 res = platform_get_resource(pdev, IORESOURCE_MEM, 0); 942 928 ··· 954 952 } 955 953 956 954 ctx->driver_data = drm_fimd_get_driver_data(pdev); 957 - ctx->vidcon0 = pdata->vidcon0; 958 - ctx->vidcon1 = pdata->vidcon1; 959 - ctx->default_win = pdata->default_win; 960 - ctx->panel = panel; 961 955 DRM_INIT_WAITQUEUE(&ctx->wait_vsync_queue); 962 956 atomic_set(&ctx->wait_vsync_event, 0); 963 957 ··· 970 972 971 973 pm_runtime_enable(dev); 972 974 pm_runtime_get_sync(dev); 973 - 974 - ctx->clkdiv = fimd_calc_clkdiv(ctx, &panel->timing); 975 - panel->timing.pixclock = clk_get_rate(ctx->lcd_clk) / ctx->clkdiv; 976 - 977 - DRM_DEBUG_KMS("pixel clock = %d, clkdiv = %d\n", 978 - panel->timing.pixclock, ctx->clkdiv); 979 975 980 976 for (win = 0; win < WINDOWS_NR; win++) 981 977 fimd_clear_win(ctx, win); ··· 1059 1067 } 1060 1068 #endif 1061 1069 1062 - static struct platform_device_id fimd_driver_ids[] = { 1063 - { 1064 - .name = "s3c64xx-fb", 1065 - .driver_data = (unsigned long)&s3c64xx_fimd_driver_data, 1066 - }, { 1067 - .name = "exynos4-fb", 1068 - .driver_data = (unsigned long)&exynos4_fimd_driver_data, 1069 - }, { 1070 - .name = "exynos5-fb", 1071 - .driver_data = (unsigned long)&exynos5_fimd_driver_data, 1072 - }, 1073 - {}, 1074 - }; 1075 - 1076 1070 static const struct dev_pm_ops fimd_pm_ops = { 1077 1071 SET_SYSTEM_SLEEP_PM_OPS(fimd_suspend, fimd_resume) 1078 1072 SET_RUNTIME_PM_OPS(fimd_runtime_suspend, fimd_runtime_resume, NULL) ··· 1067 1089 struct platform_driver fimd_driver = { 1068 1090 .probe = fimd_probe, 1069 1091 .remove = fimd_remove, 1070 - .id_table = fimd_driver_ids, 1071 1092 .driver = { 1072 1093 .name = "exynos4-fb", 1073 1094 .owner = THIS_MODULE, 1074 1095 .pm = &fimd_pm_ops, 1075 - .of_match_table = of_match_ptr(fimd_driver_dt_match), 1096 + .of_match_table = fimd_driver_dt_match, 1076 1097 }, 1077 1098 };
+33 -27
drivers/gpu/drm/exynos/exynos_drm_g2d.c
··· 23 23 #include <drm/drmP.h> 24 24 #include <drm/exynos_drm.h> 25 25 #include "exynos_drm_drv.h" 26 + #include "exynos_drm_g2d.h" 26 27 #include "exynos_drm_gem.h" 27 28 #include "exynos_drm_iommu.h" 28 29 ··· 447 446 } 448 447 449 448 g2d_userptr = kzalloc(sizeof(*g2d_userptr), GFP_KERNEL); 450 - if (!g2d_userptr) { 451 - DRM_ERROR("failed to allocate g2d_userptr.\n"); 449 + if (!g2d_userptr) 452 450 return ERR_PTR(-ENOMEM); 453 - } 454 451 455 452 atomic_set(&g2d_userptr->refcount, 1); 456 453 ··· 498 499 499 500 sgt = kzalloc(sizeof(*sgt), GFP_KERNEL); 500 501 if (!sgt) { 501 - DRM_ERROR("failed to allocate sg table.\n"); 502 502 ret = -ENOMEM; 503 503 goto err_free_userptr; 504 504 } ··· 806 808 int ret; 807 809 808 810 ret = pm_runtime_get_sync(g2d->dev); 809 - if (ret < 0) { 810 - dev_warn(g2d->dev, "failed pm power on.\n"); 811 + if (ret < 0) 811 812 return; 812 - } 813 - 814 - ret = clk_prepare_enable(g2d->gate_clk); 815 - if (ret < 0) { 816 - dev_warn(g2d->dev, "failed to enable clock.\n"); 817 - pm_runtime_put_sync(g2d->dev); 818 - return; 819 - } 820 813 821 814 writel_relaxed(node->dma_addr, g2d->regs + G2D_DMA_SFR_BASE_ADDR); 822 815 writel_relaxed(G2D_DMA_START, g2d->regs + G2D_DMA_COMMAND); ··· 860 871 runqueue_work); 861 872 862 873 mutex_lock(&g2d->runqueue_mutex); 863 - clk_disable_unprepare(g2d->gate_clk); 864 874 pm_runtime_put_sync(g2d->dev); 865 875 866 876 complete(&g2d->runqueue_node->complete); ··· 1084 1096 1085 1097 e = kzalloc(sizeof(*node->event), GFP_KERNEL); 1086 1098 if (!e) { 1087 - dev_err(dev, "failed to allocate event\n"); 1088 - 1089 1099 spin_lock_irqsave(&drm_dev->event_lock, flags); 1090 1100 file->event_space += sizeof(e->event); 1091 1101 spin_unlock_irqrestore(&drm_dev->event_lock, flags); ··· 1313 1327 struct exynos_drm_g2d_private *g2d_priv; 1314 1328 1315 1329 g2d_priv = kzalloc(sizeof(*g2d_priv), GFP_KERNEL); 1316 - if (!g2d_priv) { 1317 - dev_err(dev, "failed to allocate g2d private data\n"); 1330 + if (!g2d_priv) 1318 1331 return -ENOMEM; 1319 - } 1320 1332 1321 1333 g2d_priv->dev = dev; 1322 1334 file_priv->g2d_priv = g2d_priv; ··· 1370 1386 int ret; 1371 1387 1372 1388 g2d = devm_kzalloc(dev, sizeof(*g2d), GFP_KERNEL); 1373 - if (!g2d) { 1374 - dev_err(dev, "failed to allocate driver data\n"); 1389 + if (!g2d) 1375 1390 return -ENOMEM; 1376 - } 1377 1391 1378 1392 g2d->runqueue_slab = kmem_cache_create("g2d_runqueue_slab", 1379 1393 sizeof(struct g2d_runqueue_node), 0, 0, NULL); ··· 1506 1524 } 1507 1525 #endif 1508 1526 1509 - static SIMPLE_DEV_PM_OPS(g2d_pm_ops, g2d_suspend, g2d_resume); 1527 + #ifdef CONFIG_PM_RUNTIME 1528 + static int g2d_runtime_suspend(struct device *dev) 1529 + { 1530 + struct g2d_data *g2d = dev_get_drvdata(dev); 1510 1531 1511 - #ifdef CONFIG_OF 1532 + clk_disable_unprepare(g2d->gate_clk); 1533 + 1534 + return 0; 1535 + } 1536 + 1537 + static int g2d_runtime_resume(struct device *dev) 1538 + { 1539 + struct g2d_data *g2d = dev_get_drvdata(dev); 1540 + int ret; 1541 + 1542 + ret = clk_prepare_enable(g2d->gate_clk); 1543 + if (ret < 0) 1544 + dev_warn(dev, "failed to enable clock.\n"); 1545 + 1546 + return ret; 1547 + } 1548 + #endif 1549 + 1550 + static const struct dev_pm_ops g2d_pm_ops = { 1551 + SET_SYSTEM_SLEEP_PM_OPS(g2d_suspend, g2d_resume) 1552 + SET_RUNTIME_PM_OPS(g2d_runtime_suspend, g2d_runtime_resume, NULL) 1553 + }; 1554 + 1512 1555 static const struct of_device_id exynos_g2d_match[] = { 1513 1556 { .compatible = "samsung,exynos5250-g2d" }, 1514 1557 {}, 1515 1558 }; 1516 - #endif 1517 1559 1518 1560 struct platform_driver g2d_driver = { 1519 1561 .probe = g2d_probe, ··· 1546 1540 .name = "s5p-g2d", 1547 1541 .owner = THIS_MODULE, 1548 1542 .pm = &g2d_pm_ops, 1549 - .of_match_table = of_match_ptr(exynos_g2d_match), 1543 + .of_match_table = exynos_g2d_match, 1550 1544 }, 1551 1545 };
+14 -3
drivers/gpu/drm/exynos/exynos_drm_gem.c
··· 18 18 #include "exynos_drm_drv.h" 19 19 #include "exynos_drm_gem.h" 20 20 #include "exynos_drm_buf.h" 21 + #include "exynos_drm_iommu.h" 21 22 22 23 static unsigned int convert_to_vm_err_msg(int msg) 23 24 { ··· 192 191 int ret; 193 192 194 193 exynos_gem_obj = kzalloc(sizeof(*exynos_gem_obj), GFP_KERNEL); 195 - if (!exynos_gem_obj) { 196 - DRM_ERROR("failed to allocate exynos gem object\n"); 194 + if (!exynos_gem_obj) 197 195 return NULL; 198 - } 199 196 200 197 exynos_gem_obj->size = size; 201 198 obj = &exynos_gem_obj->base; ··· 667 668 668 669 exynos_gem_obj = exynos_drm_gem_create(dev, EXYNOS_BO_CONTIG | 669 670 EXYNOS_BO_WC, args->size); 671 + /* 672 + * If physically contiguous memory allocation fails and if IOMMU is 673 + * supported then try to get buffer from non physically contiguous 674 + * memory area. 675 + */ 676 + if (IS_ERR(exynos_gem_obj) && is_drm_iommu_supported(dev)) { 677 + dev_warn(dev->dev, "contiguous FB allocation failed, falling back to non-contiguous\n"); 678 + exynos_gem_obj = exynos_drm_gem_create(dev, 679 + EXYNOS_BO_NONCONTIG | EXYNOS_BO_WC, 680 + args->size); 681 + } 682 + 670 683 if (IS_ERR(exynos_gem_obj)) 671 684 return PTR_ERR(exynos_gem_obj); 672 685
+2 -3
drivers/gpu/drm/exynos/exynos_drm_gsc.c
··· 20 20 #include <drm/drmP.h> 21 21 #include <drm/exynos_drm.h> 22 22 #include "regs-gsc.h" 23 + #include "exynos_drm_drv.h" 23 24 #include "exynos_drm_ipp.h" 24 25 #include "exynos_drm_gsc.h" 25 26 ··· 1338 1337 struct drm_exynos_ipp_prop_list *prop_list; 1339 1338 1340 1339 prop_list = devm_kzalloc(ippdrv->dev, sizeof(*prop_list), GFP_KERNEL); 1341 - if (!prop_list) { 1342 - DRM_ERROR("failed to alloc property list.\n"); 1340 + if (!prop_list) 1343 1341 return -ENOMEM; 1344 - } 1345 1342 1346 1343 prop_list->version = 1; 1347 1344 prop_list->writeback = 1;
+1 -3
drivers/gpu/drm/exynos/exynos_drm_hdmi.c
··· 403 403 struct drm_hdmi_context *ctx; 404 404 405 405 ctx = devm_kzalloc(dev, sizeof(*ctx), GFP_KERNEL); 406 - if (!ctx) { 407 - DRM_LOG_KMS("failed to alloc common hdmi context.\n"); 406 + if (!ctx) 408 407 return -ENOMEM; 409 - } 410 408 411 409 subdrv = &ctx->subdrv; 412 410
+9
drivers/gpu/drm/exynos/exynos_drm_iommu.c
··· 47 47 48 48 dev->dma_parms = devm_kzalloc(dev, sizeof(*dev->dma_parms), 49 49 GFP_KERNEL); 50 + if (!dev->dma_parms) 51 + goto error; 52 + 50 53 dma_set_max_seg_size(dev, 0xffffffffu); 51 54 dev->archdata.mapping = mapping; 52 55 53 56 return 0; 57 + error: 58 + arm_iommu_release_mapping(mapping); 59 + return -ENOMEM; 54 60 } 55 61 56 62 /* ··· 97 91 subdrv_dev->dma_parms = devm_kzalloc(subdrv_dev, 98 92 sizeof(*subdrv_dev->dma_parms), 99 93 GFP_KERNEL); 94 + if (!subdrv_dev->dma_parms) 95 + return -ENOMEM; 96 + 100 97 dma_set_max_seg_size(subdrv_dev, 0xffffffffu); 101 98 102 99 ret = arm_iommu_attach_device(subdrv_dev, dev->archdata.mapping);
+5 -17
drivers/gpu/drm/exynos/exynos_drm_ipp.c
··· 408 408 struct drm_exynos_ipp_cmd_work *cmd_work; 409 409 410 410 cmd_work = kzalloc(sizeof(*cmd_work), GFP_KERNEL); 411 - if (!cmd_work) { 412 - DRM_ERROR("failed to alloc cmd_work.\n"); 411 + if (!cmd_work) 413 412 return ERR_PTR(-ENOMEM); 414 - } 415 413 416 414 INIT_WORK((struct work_struct *)cmd_work, ipp_sched_cmd); 417 415 ··· 421 423 struct drm_exynos_ipp_event_work *event_work; 422 424 423 425 event_work = kzalloc(sizeof(*event_work), GFP_KERNEL); 424 - if (!event_work) { 425 - DRM_ERROR("failed to alloc event_work.\n"); 426 + if (!event_work) 426 427 return ERR_PTR(-ENOMEM); 427 - } 428 428 429 429 INIT_WORK((struct work_struct *)event_work, ipp_sched_event); 430 430 ··· 478 482 479 483 /* allocate command node */ 480 484 c_node = kzalloc(sizeof(*c_node), GFP_KERNEL); 481 - if (!c_node) { 482 - DRM_ERROR("failed to allocate map node.\n"); 485 + if (!c_node) 483 486 return -ENOMEM; 484 - } 485 487 486 488 /* create property id */ 487 489 ret = ipp_create_id(&ctx->prop_idr, &ctx->prop_lock, c_node, ··· 688 694 mutex_lock(&c_node->mem_lock); 689 695 690 696 m_node = kzalloc(sizeof(*m_node), GFP_KERNEL); 691 - if (!m_node) { 692 - DRM_ERROR("failed to allocate queue node.\n"); 697 + if (!m_node) 693 698 goto err_unlock; 694 - } 695 699 696 700 /* clear base address for error handling */ 697 701 memset(&buf_info, 0x0, sizeof(buf_info)); ··· 790 798 DRM_DEBUG_KMS("ops_id[%d]buf_id[%d]\n", qbuf->ops_id, qbuf->buf_id); 791 799 792 800 e = kzalloc(sizeof(*e), GFP_KERNEL); 793 - 794 801 if (!e) { 795 - DRM_ERROR("failed to allocate event.\n"); 796 802 spin_lock_irqsave(&drm_dev->event_lock, flags); 797 803 file->event_space += sizeof(e->event); 798 804 spin_unlock_irqrestore(&drm_dev->event_lock, flags); ··· 1770 1780 struct exynos_drm_ipp_private *priv; 1771 1781 1772 1782 priv = kzalloc(sizeof(*priv), GFP_KERNEL); 1773 - if (!priv) { 1774 - DRM_ERROR("failed to allocate priv.\n"); 1783 + if (!priv) 1775 1784 return -ENOMEM; 1776 - } 1777 1785 priv->dev = dev; 1778 1786 file_priv->ipp_priv = priv; 1779 1787
+2 -3
drivers/gpu/drm/exynos/exynos_drm_plane.c
··· 16 16 #include "exynos_drm_encoder.h" 17 17 #include "exynos_drm_fb.h" 18 18 #include "exynos_drm_gem.h" 19 + #include "exynos_drm_plane.h" 19 20 20 21 #define to_exynos_plane(x) container_of(x, struct exynos_plane, base) 21 22 ··· 265 264 int err; 266 265 267 266 exynos_plane = kzalloc(sizeof(struct exynos_plane), GFP_KERNEL); 268 - if (!exynos_plane) { 269 - DRM_ERROR("failed to allocate plane\n"); 267 + if (!exynos_plane) 270 268 return NULL; 271 - } 272 269 273 270 err = drm_plane_init(dev, &exynos_plane->base, possible_crtcs, 274 271 &exynos_plane_funcs, formats, ARRAY_SIZE(formats),
+84 -35
drivers/gpu/drm/exynos/exynos_drm_rotator.c
··· 21 21 #include <drm/exynos_drm.h> 22 22 #include "regs-rotator.h" 23 23 #include "exynos_drm.h" 24 + #include "exynos_drm_drv.h" 24 25 #include "exynos_drm_ipp.h" 25 26 26 27 /* ··· 472 471 struct drm_exynos_ipp_prop_list *prop_list; 473 472 474 473 prop_list = devm_kzalloc(ippdrv->dev, sizeof(*prop_list), GFP_KERNEL); 475 - if (!prop_list) { 476 - DRM_ERROR("failed to alloc property list.\n"); 474 + if (!prop_list) 477 475 return -ENOMEM; 478 - } 479 476 480 477 prop_list->version = 1; 481 478 prop_list->flip = (1 << EXYNOS_DRM_FLIP_VERTICAL) | ··· 630 631 return 0; 631 632 } 632 633 634 + static struct rot_limit_table rot_limit_tbl_4210 = { 635 + .ycbcr420_2p = { 636 + .min_w = 32, 637 + .min_h = 32, 638 + .max_w = SZ_64K, 639 + .max_h = SZ_64K, 640 + .align = 3, 641 + }, 642 + .rgb888 = { 643 + .min_w = 8, 644 + .min_h = 8, 645 + .max_w = SZ_16K, 646 + .max_h = SZ_16K, 647 + .align = 2, 648 + }, 649 + }; 650 + 651 + static struct rot_limit_table rot_limit_tbl_4x12 = { 652 + .ycbcr420_2p = { 653 + .min_w = 32, 654 + .min_h = 32, 655 + .max_w = SZ_32K, 656 + .max_h = SZ_32K, 657 + .align = 3, 658 + }, 659 + .rgb888 = { 660 + .min_w = 8, 661 + .min_h = 8, 662 + .max_w = SZ_8K, 663 + .max_h = SZ_8K, 664 + .align = 2, 665 + }, 666 + }; 667 + 668 + static struct rot_limit_table rot_limit_tbl_5250 = { 669 + .ycbcr420_2p = { 670 + .min_w = 32, 671 + .min_h = 32, 672 + .max_w = SZ_32K, 673 + .max_h = SZ_32K, 674 + .align = 3, 675 + }, 676 + .rgb888 = { 677 + .min_w = 8, 678 + .min_h = 8, 679 + .max_w = SZ_8K, 680 + .max_h = SZ_8K, 681 + .align = 1, 682 + }, 683 + }; 684 + 685 + static const struct of_device_id exynos_rotator_match[] = { 686 + { 687 + .compatible = "samsung,exynos4210-rotator", 688 + .data = &rot_limit_tbl_4210, 689 + }, 690 + { 691 + .compatible = "samsung,exynos4212-rotator", 692 + .data = &rot_limit_tbl_4x12, 693 + }, 694 + { 695 + .compatible = "samsung,exynos5250-rotator", 696 + .data = &rot_limit_tbl_5250, 697 + }, 698 + {}, 699 + }; 700 + 633 701 static int rotator_probe(struct platform_device *pdev) 634 702 { 635 703 struct device *dev = &pdev->dev; 636 704 struct rot_context *rot; 637 705 struct exynos_drm_ippdrv *ippdrv; 706 + const struct of_device_id *match; 638 707 int ret; 639 708 640 - rot = devm_kzalloc(dev, sizeof(*rot), GFP_KERNEL); 641 - if (!rot) { 642 - dev_err(dev, "failed to allocate rot\n"); 643 - return -ENOMEM; 709 + if (!dev->of_node) { 710 + dev_err(dev, "cannot find of_node.\n"); 711 + return -ENODEV; 644 712 } 645 713 646 - rot->limit_tbl = (struct rot_limit_table *) 647 - platform_get_device_id(pdev)->driver_data; 714 + rot = devm_kzalloc(dev, sizeof(*rot), GFP_KERNEL); 715 + if (!rot) 716 + return -ENOMEM; 717 + 718 + match = of_match_node(exynos_rotator_match, dev->of_node); 719 + if (!match) { 720 + dev_err(dev, "failed to match node\n"); 721 + return -ENODEV; 722 + } 723 + rot->limit_tbl = (struct rot_limit_table *)match->data; 648 724 649 725 rot->regs_res = platform_get_resource(pdev, IORESOURCE_MEM, 0); 650 726 rot->regs = devm_ioremap_resource(dev, rot->regs_res); ··· 791 717 return 0; 792 718 } 793 719 794 - static struct rot_limit_table rot_limit_tbl = { 795 - .ycbcr420_2p = { 796 - .min_w = 32, 797 - .min_h = 32, 798 - .max_w = SZ_32K, 799 - .max_h = SZ_32K, 800 - .align = 3, 801 - }, 802 - .rgb888 = { 803 - .min_w = 8, 804 - .min_h = 8, 805 - .max_w = SZ_8K, 806 - .max_h = SZ_8K, 807 - .align = 2, 808 - }, 809 - }; 810 - 811 - static struct platform_device_id rotator_driver_ids[] = { 812 - { 813 - .name = "exynos-rot", 814 - .driver_data = (unsigned long)&rot_limit_tbl, 815 - }, 816 - {}, 817 - }; 818 - 819 720 static int rotator_clk_crtl(struct rot_context *rot, bool enable) 820 721 { 821 722 if (enable) { ··· 852 803 struct platform_driver rotator_driver = { 853 804 .probe = rotator_probe, 854 805 .remove = rotator_remove, 855 - .id_table = rotator_driver_ids, 856 806 .driver = { 857 807 .name = "exynos-rot", 858 808 .owner = THIS_MODULE, 859 809 .pm = &rotator_pm_ops, 810 + .of_match_table = exynos_rotator_match, 860 811 }, 861 812 };
+1
drivers/gpu/drm/exynos/exynos_drm_vidi.c
··· 23 23 #include "exynos_drm_drv.h" 24 24 #include "exynos_drm_crtc.h" 25 25 #include "exynos_drm_encoder.h" 26 + #include "exynos_drm_vidi.h" 26 27 27 28 /* vidi has totally three virtual windows. */ 28 29 #define WINDOWS_NR 3
+17 -70
drivers/gpu/drm/exynos/exynos_hdmi.c
··· 32 32 #include <linux/clk.h> 33 33 #include <linux/regulator/consumer.h> 34 34 #include <linux/io.h> 35 + #include <linux/of.h> 35 36 #include <linux/of_gpio.h> 36 37 37 38 #include <drm/exynos_drm.h> ··· 1825 1824 1826 1825 res->regul_bulk = devm_kzalloc(dev, ARRAY_SIZE(supply) * 1827 1826 sizeof(res->regul_bulk[0]), GFP_KERNEL); 1828 - if (!res->regul_bulk) { 1829 - DRM_ERROR("failed to get memory for regulators\n"); 1827 + if (!res->regul_bulk) 1830 1828 goto fail; 1831 - } 1832 1829 for (i = 0; i < ARRAY_SIZE(supply); ++i) { 1833 1830 res->regul_bulk[i].supply = supply[i]; 1834 1831 res->regul_bulk[i].consumer = NULL; ··· 1858 1859 hdmi_hdmiphy = hdmiphy; 1859 1860 } 1860 1861 1861 - #ifdef CONFIG_OF 1862 1862 static struct s5p_hdmi_platform_data *drm_hdmi_dt_parse_pdata 1863 1863 (struct device *dev) 1864 1864 { ··· 1866 1868 u32 value; 1867 1869 1868 1870 pd = devm_kzalloc(dev, sizeof(*pd), GFP_KERNEL); 1869 - if (!pd) { 1870 - DRM_ERROR("memory allocation for pdata failed\n"); 1871 + if (!pd) 1871 1872 goto err_data; 1872 - } 1873 1873 1874 1874 if (!of_find_property(np, "hpd-gpio", &value)) { 1875 1875 DRM_ERROR("no hpd gpio property found\n"); ··· 1881 1885 err_data: 1882 1886 return NULL; 1883 1887 } 1884 - #else 1885 - static struct s5p_hdmi_platform_data *drm_hdmi_dt_parse_pdata 1886 - (struct device *dev) 1887 - { 1888 - return NULL; 1889 - } 1890 - #endif 1891 1888 1892 - static struct platform_device_id hdmi_driver_types[] = { 1893 - { 1894 - .name = "s5pv210-hdmi", 1895 - .driver_data = HDMI_TYPE13, 1896 - }, { 1897 - .name = "exynos4-hdmi", 1898 - .driver_data = HDMI_TYPE13, 1899 - }, { 1900 - .name = "exynos4-hdmi14", 1901 - .driver_data = HDMI_TYPE14, 1902 - }, { 1903 - .name = "exynos5-hdmi", 1904 - .driver_data = HDMI_TYPE14, 1905 - }, { 1906 - /* end node */ 1907 - } 1908 - }; 1909 - 1910 - #ifdef CONFIG_OF 1911 1889 static struct of_device_id hdmi_match_types[] = { 1912 1890 { 1913 1891 .compatible = "samsung,exynos5-hdmi", ··· 1893 1923 /* end node */ 1894 1924 } 1895 1925 }; 1896 - #endif 1897 1926 1898 1927 static int hdmi_probe(struct platform_device *pdev) 1899 1928 { ··· 1901 1932 struct hdmi_context *hdata; 1902 1933 struct s5p_hdmi_platform_data *pdata; 1903 1934 struct resource *res; 1935 + const struct of_device_id *match; 1904 1936 int ret; 1905 1937 1906 - if (dev->of_node) { 1907 - pdata = drm_hdmi_dt_parse_pdata(dev); 1908 - if (IS_ERR(pdata)) { 1909 - DRM_ERROR("failed to parse dt\n"); 1910 - return PTR_ERR(pdata); 1911 - } 1912 - } else { 1913 - pdata = dev->platform_data; 1914 - } 1938 + if (!dev->of_node) 1939 + return -ENODEV; 1915 1940 1916 - if (!pdata) { 1917 - DRM_ERROR("no platform data specified\n"); 1941 + pdata = drm_hdmi_dt_parse_pdata(dev); 1942 + if (!pdata) 1918 1943 return -EINVAL; 1919 - } 1920 1944 1921 - drm_hdmi_ctx = devm_kzalloc(dev, sizeof(*drm_hdmi_ctx), 1922 - GFP_KERNEL); 1923 - if (!drm_hdmi_ctx) { 1924 - DRM_ERROR("failed to allocate common hdmi context.\n"); 1945 + drm_hdmi_ctx = devm_kzalloc(dev, sizeof(*drm_hdmi_ctx), GFP_KERNEL); 1946 + if (!drm_hdmi_ctx) 1925 1947 return -ENOMEM; 1926 - } 1927 1948 1928 - hdata = devm_kzalloc(dev, sizeof(struct hdmi_context), 1929 - GFP_KERNEL); 1930 - if (!hdata) { 1931 - DRM_ERROR("out of memory\n"); 1949 + hdata = devm_kzalloc(dev, sizeof(struct hdmi_context), GFP_KERNEL); 1950 + if (!hdata) 1932 1951 return -ENOMEM; 1933 - } 1934 1952 1935 1953 mutex_init(&hdata->hdmi_mutex); 1936 1954 ··· 1926 1970 1927 1971 platform_set_drvdata(pdev, drm_hdmi_ctx); 1928 1972 1929 - if (dev->of_node) { 1930 - const struct of_device_id *match; 1931 - match = of_match_node(of_match_ptr(hdmi_match_types), 1932 - dev->of_node); 1933 - if (match == NULL) 1934 - return -ENODEV; 1935 - hdata->type = (enum hdmi_type)match->data; 1936 - } else { 1937 - hdata->type = (enum hdmi_type)platform_get_device_id 1938 - (pdev)->driver_data; 1939 - } 1973 + match = of_match_node(hdmi_match_types, dev->of_node); 1974 + if (!match) 1975 + return -ENODEV; 1976 + hdata->type = (enum hdmi_type)match->data; 1940 1977 1941 1978 hdata->hpd_gpio = pdata->hpd_gpio; 1942 1979 hdata->dev = dev; 1943 1980 1944 1981 ret = hdmi_resources_init(hdata); 1945 - 1946 1982 if (ret) { 1947 1983 DRM_ERROR("hdmi_resources_init failed\n"); 1948 1984 return -EINVAL; ··· 2089 2141 struct platform_driver hdmi_driver = { 2090 2142 .probe = hdmi_probe, 2091 2143 .remove = hdmi_remove, 2092 - .id_table = hdmi_driver_types, 2093 2144 .driver = { 2094 2145 .name = "exynos-hdmi", 2095 2146 .owner = THIS_MODULE, 2096 2147 .pm = &hdmi_pm_ops, 2097 - .of_match_table = of_match_ptr(hdmi_match_types), 2148 + .of_match_table = hdmi_match_types, 2098 2149 }, 2099 2150 };
+2 -10
drivers/gpu/drm/exynos/exynos_hdmiphy.c
··· 15 15 16 16 #include <linux/kernel.h> 17 17 #include <linux/i2c.h> 18 + #include <linux/of.h> 18 19 19 20 #include "exynos_drm_drv.h" 20 21 #include "exynos_hdmi.h" ··· 40 39 return 0; 41 40 } 42 41 43 - static const struct i2c_device_id hdmiphy_id[] = { 44 - { "s5p_hdmiphy", 0 }, 45 - { "exynos5-hdmiphy", 0 }, 46 - { }, 47 - }; 48 - 49 - #ifdef CONFIG_OF 50 42 static struct of_device_id hdmiphy_match_types[] = { 51 43 { 52 44 .compatible = "samsung,exynos5-hdmiphy", ··· 51 57 /* end node */ 52 58 } 53 59 }; 54 - #endif 55 60 56 61 struct i2c_driver hdmiphy_driver = { 57 62 .driver = { 58 63 .name = "exynos-hdmiphy", 59 64 .owner = THIS_MODULE, 60 - .of_match_table = of_match_ptr(hdmiphy_match_types), 65 + .of_match_table = hdmiphy_match_types, 61 66 }, 62 - .id_table = hdmiphy_id, 63 67 .probe = hdmiphy_probe, 64 68 .remove = hdmiphy_remove, 65 69 .command = NULL,
+3 -6
drivers/gpu/drm/exynos/exynos_mixer.c
··· 30 30 #include <linux/pm_runtime.h> 31 31 #include <linux/clk.h> 32 32 #include <linux/regulator/consumer.h> 33 + #include <linux/of.h> 33 34 34 35 #include <drm/exynos_drm.h> 35 36 ··· 1186 1185 1187 1186 drm_hdmi_ctx = devm_kzalloc(dev, sizeof(*drm_hdmi_ctx), 1188 1187 GFP_KERNEL); 1189 - if (!drm_hdmi_ctx) { 1190 - DRM_ERROR("failed to allocate common hdmi context.\n"); 1188 + if (!drm_hdmi_ctx) 1191 1189 return -ENOMEM; 1192 - } 1193 1190 1194 1191 ctx = devm_kzalloc(dev, sizeof(*ctx), GFP_KERNEL); 1195 - if (!ctx) { 1196 - DRM_ERROR("failed to alloc mixer context.\n"); 1192 + if (!ctx) 1197 1193 return -ENOMEM; 1198 - } 1199 1194 1200 1195 mutex_init(&ctx->mixer_mutex); 1201 1196
+2 -1
include/drm/exynos_drm.h
··· 15 15 #define _EXYNOS_DRM_H_ 16 16 17 17 #include <uapi/drm/exynos_drm.h> 18 + #include <video/videomode.h> 18 19 19 20 /** 20 21 * A structure for lcd panel information. ··· 25 24 * @height_mm: physical size of lcd height. 26 25 */ 27 26 struct exynos_drm_panel_info { 28 - struct fb_videomode timing; 27 + struct videomode vm; 29 28 u32 width_mm; 30 29 u32 height_mm; 31 30 };