Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

drm/exynos: Pass exynos_drm_manager in manager ops instead of dev

This patch changes the manager ops callbacks from accepting the subdrv
device pointer to taking a pointer to the manager. This will allow us
to move closer to decoupling manager/display from subdrv, and subsequently
decoupling the crtc/plane from the encoder.

Signed-off-by: Sean Paul <seanpaul@chromium.org>
Signed-off-by: Inki Dae <inki.dae@samsung.com>

authored by

Sean Paul and committed by
Inki Dae
bb7704d6 4551789f

+180 -153
+1 -1
drivers/gpu/drm/exynos/exynos_drm_connector.c
··· 198 198 * resolution then get max width and height from that driver. 199 199 */ 200 200 if (ops && ops->get_max_resol) 201 - ops->get_max_resol(manager->dev, &width, &height); 201 + ops->get_max_resol(manager, &width, &height); 202 202 203 203 return drm_helper_probe_single_connector_modes(connector, width, 204 204 height);
+19 -16
drivers/gpu/drm/exynos/exynos_drm_drv.h
··· 161 161 * @win_enable: enable hardware specific overlay. 162 162 * @win_disable: disable hardware specific overlay. 163 163 */ 164 + struct exynos_drm_manager; 164 165 struct exynos_drm_manager_ops { 165 - int (*initialize)(struct device *subdrv_dev, 166 - struct drm_device *drm_dev); 167 - void (*dpms)(struct device *subdrv_dev, int mode); 168 - void (*apply)(struct device *subdrv_dev); 169 - void (*mode_fixup)(struct device *subdrv_dev, 166 + int (*initialize)(struct exynos_drm_manager *mgr, 167 + struct drm_device *drm_dev); 168 + void (*dpms)(struct exynos_drm_manager *mgr, int mode); 169 + void (*apply)(struct exynos_drm_manager *mgr); 170 + void (*mode_fixup)(struct exynos_drm_manager *mgr, 170 171 struct drm_connector *connector, 171 172 const struct drm_display_mode *mode, 172 173 struct drm_display_mode *adjusted_mode); 173 - void (*mode_set)(struct device *subdrv_dev, void *mode); 174 - void (*get_max_resol)(struct device *subdrv_dev, unsigned int *width, 175 - unsigned int *height); 176 - void (*commit)(struct device *subdrv_dev); 177 - int (*enable_vblank)(struct device *subdrv_dev); 178 - void (*disable_vblank)(struct device *subdrv_dev); 179 - void (*wait_for_vblank)(struct device *subdrv_dev); 180 - void (*win_mode_set)(struct device *subdrv_dev, 174 + void (*mode_set)(struct exynos_drm_manager *mgr, void *mode); 175 + void (*get_max_resol)(struct exynos_drm_manager *mgr, 176 + unsigned int *width, unsigned int *height); 177 + void (*commit)(struct exynos_drm_manager *mgr); 178 + int (*enable_vblank)(struct exynos_drm_manager *mgr); 179 + void (*disable_vblank)(struct exynos_drm_manager *mgr); 180 + void (*wait_for_vblank)(struct exynos_drm_manager *mgr); 181 + void (*win_mode_set)(struct exynos_drm_manager *mgr, 181 182 struct exynos_drm_overlay *overlay); 182 - void (*win_commit)(struct device *subdrv_dev, int zpos); 183 - void (*win_enable)(struct device *subdrv_dev, int zpos); 184 - void (*win_disable)(struct device *subdrv_dev, int zpos); 183 + void (*win_commit)(struct exynos_drm_manager *mgr, int zpos); 184 + void (*win_enable)(struct exynos_drm_manager *mgr, int zpos); 185 + void (*win_disable)(struct exynos_drm_manager *mgr, int zpos); 185 186 }; 186 187 187 188 /* ··· 198 197 * these callbacks should be set by specific drivers such fimd 199 198 * or hdmi driver and are used to control display devices such as 200 199 * analog tv, digital tv and lcd panel and also get timing data for them. 200 + * @ctx: A pointer to the manager's implementation specific context 201 201 */ 202 202 struct exynos_drm_manager { 203 203 struct device *dev; 204 204 int pipe; 205 205 struct exynos_drm_manager_ops *ops; 206 206 struct exynos_drm_display_ops *display_ops; 207 + void *ctx; 207 208 }; 208 209 209 210 struct exynos_drm_g2d_private {
+13 -14
drivers/gpu/drm/exynos/exynos_drm_encoder.c
··· 74 74 case DRM_MODE_DPMS_ON: 75 75 if (manager_ops && manager_ops->apply) 76 76 if (!exynos_encoder->updated) 77 - manager_ops->apply(manager->dev); 77 + manager_ops->apply(manager); 78 78 79 79 exynos_drm_connector_power(encoder, mode); 80 80 exynos_encoder->dpms = mode; ··· 107 107 list_for_each_entry(connector, &dev->mode_config.connector_list, head) { 108 108 if (connector->encoder == encoder) 109 109 if (manager_ops && manager_ops->mode_fixup) 110 - manager_ops->mode_fixup(manager->dev, connector, 110 + manager_ops->mode_fixup(manager, connector, 111 111 mode, adjusted_mode); 112 112 } 113 113 ··· 175 175 manager_ops = manager->ops; 176 176 177 177 if (manager_ops && manager_ops->mode_set) 178 - manager_ops->mode_set(manager->dev, 179 - adjusted_mode); 178 + manager_ops->mode_set(manager, adjusted_mode); 180 179 181 180 exynos_encoder->old_crtc = encoder->crtc; 182 181 } ··· 194 195 struct exynos_drm_manager_ops *manager_ops = manager->ops; 195 196 196 197 if (manager_ops && manager_ops->commit) 197 - manager_ops->commit(manager->dev); 198 + manager_ops->commit(manager); 198 199 199 200 /* 200 201 * this will avoid one issue that overlay data is updated to ··· 232 233 * real hardware. 233 234 */ 234 235 if (ops->wait_for_vblank) 235 - ops->wait_for_vblank(exynos_encoder->manager->dev); 236 + ops->wait_for_vblank(exynos_encoder->manager); 236 237 } 237 238 } 238 239 ··· 340 341 drm_encoder_helper_add(encoder, &exynos_encoder_helper_funcs); 341 342 342 343 if (manager->ops && manager->ops->initialize) { 343 - ret = manager->ops->initialize(manager->dev, dev); 344 + ret = manager->ops->initialize(manager, dev); 344 345 if (ret) { 345 346 DRM_ERROR("Manager initialize failed %d\n", ret); 346 347 goto error; ··· 407 408 return; 408 409 409 410 if (manager_ops->enable_vblank) 410 - manager_ops->enable_vblank(manager->dev); 411 + manager_ops->enable_vblank(manager); 411 412 } 412 413 413 414 void exynos_drm_disable_vblank(struct drm_encoder *encoder, void *data) ··· 421 422 return; 422 423 423 424 if (manager_ops->disable_vblank) 424 - manager_ops->disable_vblank(manager->dev); 425 + manager_ops->disable_vblank(manager); 425 426 } 426 427 427 428 void exynos_drm_encoder_crtc_dpms(struct drm_encoder *encoder, void *data) ··· 432 433 int mode = *(int *)data; 433 434 434 435 if (manager_ops && manager_ops->dpms) 435 - manager_ops->dpms(manager->dev, mode); 436 + manager_ops->dpms(manager, mode); 436 437 437 438 /* 438 439 * if this condition is ok then it means that the crtc is already ··· 466 467 struct exynos_drm_overlay *overlay = data; 467 468 468 469 if (manager_ops && manager_ops->win_mode_set) 469 - manager_ops->win_mode_set(manager->dev, overlay); 470 + manager_ops->win_mode_set(manager, overlay); 470 471 } 471 472 472 473 void exynos_drm_encoder_plane_commit(struct drm_encoder *encoder, void *data) ··· 480 481 zpos = *(int *)data; 481 482 482 483 if (manager_ops && manager_ops->win_commit) 483 - manager_ops->win_commit(manager->dev, zpos); 484 + manager_ops->win_commit(manager, zpos); 484 485 } 485 486 486 487 void exynos_drm_encoder_plane_enable(struct drm_encoder *encoder, void *data) ··· 494 495 zpos = *(int *)data; 495 496 496 497 if (manager_ops && manager_ops->win_enable) 497 - manager_ops->win_enable(manager->dev, zpos); 498 + manager_ops->win_enable(manager, zpos); 498 499 } 499 500 500 501 void exynos_drm_encoder_plane_disable(struct drm_encoder *encoder, void *data) ··· 508 509 zpos = *(int *)data; 509 510 510 511 if (manager_ops && manager_ops->win_disable) 511 - manager_ops->win_disable(manager->dev, zpos); 512 + manager_ops->win_disable(manager, zpos); 512 513 }
+61 -53
drivers/gpu/drm/exynos/exynos_drm_fimd.c
··· 62 62 /* FIMD has totally five hardware windows. */ 63 63 #define WINDOWS_NR 5 64 64 65 - #define get_fimd_context(dev) platform_get_drvdata(to_platform_device(dev)) 65 + #define get_fimd_manager(mgr) platform_get_drvdata(to_platform_device(dev)) 66 66 67 67 struct fimd_driver_data { 68 68 unsigned int timing_base; ··· 106 106 107 107 struct fimd_context { 108 108 struct exynos_drm_subdrv subdrv; 109 + struct device *dev; 109 110 struct drm_device *drm_dev; 110 111 int irq; 111 112 struct drm_crtc *crtc; ··· 156 155 157 156 static void *fimd_get_panel(struct device *dev) 158 157 { 159 - struct fimd_context *ctx = get_fimd_context(dev); 158 + struct exynos_drm_manager *mgr = get_fimd_manager(dev); 159 + struct fimd_context *ctx = mgr->ctx; 160 160 161 161 return &ctx->panel; 162 162 } ··· 184 182 .power_on = fimd_display_power_on, 185 183 }; 186 184 187 - static int fimd_mgr_initialize(struct device *subdrv_dev, 188 - struct drm_device *drm_dev) 185 + static int fimd_mgr_initialize(struct exynos_drm_manager *mgr, 186 + struct drm_device *drm_dev) 189 187 { 190 - struct fimd_context *ctx = get_fimd_context(subdrv_dev); 188 + struct fimd_context *ctx = mgr->ctx; 191 189 192 190 ctx->drm_dev = drm_dev; 193 191 194 192 return 0; 195 193 } 196 194 197 - static void fimd_dpms(struct device *subdrv_dev, int mode) 195 + static void fimd_dpms(struct exynos_drm_manager *mgr, int mode) 198 196 { 199 - struct fimd_context *ctx = get_fimd_context(subdrv_dev); 197 + struct fimd_context *ctx = mgr->ctx; 200 198 201 199 DRM_DEBUG_KMS("%d\n", mode); 202 200 ··· 211 209 * clk_enable could be called double time. 212 210 */ 213 211 if (ctx->suspended) 214 - pm_runtime_get_sync(subdrv_dev); 212 + pm_runtime_get_sync(ctx->dev); 215 213 break; 216 214 case DRM_MODE_DPMS_STANDBY: 217 215 case DRM_MODE_DPMS_SUSPEND: 218 216 case DRM_MODE_DPMS_OFF: 219 217 if (!ctx->suspended) 220 - pm_runtime_put_sync(subdrv_dev); 218 + pm_runtime_put_sync(ctx->dev); 221 219 break; 222 220 default: 223 221 DRM_DEBUG_KMS("unspecified mode %d\n", mode); ··· 227 225 mutex_unlock(&ctx->lock); 228 226 } 229 227 230 - static void fimd_apply(struct device *subdrv_dev) 228 + static void fimd_apply(struct exynos_drm_manager *mgr) 231 229 { 232 - struct fimd_context *ctx = get_fimd_context(subdrv_dev); 233 - struct exynos_drm_manager *mgr = ctx->subdrv.manager; 230 + struct fimd_context *ctx = mgr->ctx; 234 231 struct exynos_drm_manager_ops *mgr_ops = mgr->ops; 235 232 struct fimd_win_data *win_data; 236 233 int i; ··· 237 236 for (i = 0; i < WINDOWS_NR; i++) { 238 237 win_data = &ctx->win_data[i]; 239 238 if (win_data->enabled && (mgr_ops && mgr_ops->win_commit)) 240 - mgr_ops->win_commit(subdrv_dev, i); 239 + mgr_ops->win_commit(mgr, i); 241 240 } 242 241 243 242 if (mgr_ops && mgr_ops->commit) 244 - mgr_ops->commit(subdrv_dev); 243 + mgr_ops->commit(mgr); 245 244 } 246 245 247 - static void fimd_commit(struct device *dev) 246 + static void fimd_commit(struct exynos_drm_manager *mgr) 248 247 { 249 - struct fimd_context *ctx = get_fimd_context(dev); 248 + struct fimd_context *ctx = mgr->ctx; 250 249 struct exynos_drm_panel_info *panel = &ctx->panel; 251 250 struct videomode *vm = &panel->vm; 252 251 struct fimd_driver_data *driver_data; ··· 300 299 writel(val, ctx->regs + VIDCON0); 301 300 } 302 301 303 - static int fimd_enable_vblank(struct device *dev) 302 + static int fimd_enable_vblank(struct exynos_drm_manager *mgr) 304 303 { 305 - struct fimd_context *ctx = get_fimd_context(dev); 304 + struct fimd_context *ctx = mgr->ctx; 306 305 u32 val; 307 306 308 307 if (ctx->suspended) ··· 325 324 return 0; 326 325 } 327 326 328 - static void fimd_disable_vblank(struct device *dev) 327 + static void fimd_disable_vblank(struct exynos_drm_manager *mgr) 329 328 { 330 - struct fimd_context *ctx = get_fimd_context(dev); 329 + struct fimd_context *ctx = mgr->ctx; 331 330 u32 val; 332 331 333 332 if (ctx->suspended) ··· 343 342 } 344 343 } 345 344 346 - static void fimd_wait_for_vblank(struct device *dev) 345 + static void fimd_wait_for_vblank(struct exynos_drm_manager *mgr) 347 346 { 348 - struct fimd_context *ctx = get_fimd_context(dev); 347 + struct fimd_context *ctx = mgr->ctx; 349 348 350 349 if (ctx->suspended) 351 350 return; ··· 362 361 DRM_DEBUG_KMS("vblank wait timed out.\n"); 363 362 } 364 363 365 - static void fimd_win_mode_set(struct device *dev, 366 - struct exynos_drm_overlay *overlay) 364 + static void fimd_win_mode_set(struct exynos_drm_manager *mgr, 365 + struct exynos_drm_overlay *overlay) 367 366 { 368 - struct fimd_context *ctx = get_fimd_context(dev); 367 + struct fimd_context *ctx = mgr->ctx; 369 368 struct fimd_win_data *win_data; 370 369 int win; 371 370 unsigned long offset; 372 371 373 372 if (!overlay) { 374 - dev_err(dev, "overlay is NULL\n"); 373 + DRM_ERROR("overlay is NULL\n"); 375 374 return; 376 375 } 377 376 ··· 411 410 overlay->fb_width, overlay->crtc_width); 412 411 } 413 412 414 - static void fimd_win_set_pixfmt(struct device *dev, unsigned int win) 413 + static void fimd_win_set_pixfmt(struct fimd_context *ctx, unsigned int win) 415 414 { 416 - struct fimd_context *ctx = get_fimd_context(dev); 417 415 struct fimd_win_data *win_data = &ctx->win_data[win]; 418 416 unsigned long val; 419 417 ··· 468 468 writel(val, ctx->regs + WINCON(win)); 469 469 } 470 470 471 - static void fimd_win_set_colkey(struct device *dev, unsigned int win) 471 + static void fimd_win_set_colkey(struct fimd_context *ctx, unsigned int win) 472 472 { 473 - struct fimd_context *ctx = get_fimd_context(dev); 474 473 unsigned int keycon0 = 0, keycon1 = 0; 475 474 476 475 keycon0 = ~(WxKEYCON0_KEYBL_EN | WxKEYCON0_KEYEN_F | ··· 508 509 writel(val, ctx->regs + reg); 509 510 } 510 511 511 - static void fimd_win_commit(struct device *dev, int zpos) 512 + static void fimd_win_commit(struct exynos_drm_manager *mgr, int zpos) 512 513 { 513 - struct fimd_context *ctx = get_fimd_context(dev); 514 + struct fimd_context *ctx = mgr->ctx; 514 515 struct fimd_win_data *win_data; 515 516 int win = zpos; 516 517 unsigned long val, alpha, size; ··· 605 606 DRM_DEBUG_KMS("osd size = 0x%x\n", (unsigned int)val); 606 607 } 607 608 608 - fimd_win_set_pixfmt(dev, win); 609 + fimd_win_set_pixfmt(ctx, win); 609 610 610 611 /* hardware window 0 doesn't support color key. */ 611 612 if (win != 0) 612 - fimd_win_set_colkey(dev, win); 613 + fimd_win_set_colkey(ctx, win); 613 614 614 615 /* wincon */ 615 616 val = readl(ctx->regs + WINCON(win)); ··· 628 629 win_data->enabled = true; 629 630 } 630 631 631 - static void fimd_win_disable(struct device *dev, int zpos) 632 + static void fimd_win_disable(struct exynos_drm_manager *mgr, int zpos) 632 633 { 633 - struct fimd_context *ctx = get_fimd_context(dev); 634 + struct fimd_context *ctx = mgr->ctx; 634 635 struct fimd_win_data *win_data; 635 636 int win = zpos; 636 637 u32 val; ··· 837 838 838 839 static void fimd_window_suspend(struct device *dev) 839 840 { 840 - struct fimd_context *ctx = get_fimd_context(dev); 841 + struct exynos_drm_manager *mgr = get_fimd_manager(dev); 842 + struct fimd_context *ctx = mgr->ctx; 841 843 struct fimd_win_data *win_data; 842 844 int i; 843 845 844 846 for (i = 0; i < WINDOWS_NR; i++) { 845 847 win_data = &ctx->win_data[i]; 846 848 win_data->resume = win_data->enabled; 847 - fimd_win_disable(dev, i); 849 + fimd_win_disable(mgr, i); 848 850 } 849 - fimd_wait_for_vblank(dev); 851 + fimd_wait_for_vblank(mgr); 850 852 } 851 853 852 854 static void fimd_window_resume(struct device *dev) 853 855 { 854 - struct fimd_context *ctx = get_fimd_context(dev); 856 + struct exynos_drm_manager *mgr = get_fimd_manager(dev); 857 + struct fimd_context *ctx = mgr->ctx; 855 858 struct fimd_win_data *win_data; 856 859 int i; 857 860 ··· 864 863 } 865 864 } 866 865 867 - static int fimd_activate(struct fimd_context *ctx, bool enable) 866 + static int fimd_activate(struct exynos_drm_manager *mgr, bool enable) 868 867 { 868 + struct fimd_context *ctx = mgr->ctx; 869 869 struct device *dev = ctx->subdrv.dev; 870 + 870 871 if (enable) { 871 872 int ret; 872 873 ··· 880 877 881 878 /* if vblank was enabled status, enable it again. */ 882 879 if (test_and_clear_bit(0, &ctx->irq_flags)) 883 - fimd_enable_vblank(dev); 880 + fimd_enable_vblank(mgr); 884 881 885 882 fimd_window_resume(dev); 886 883 } else { ··· 933 930 if (!ctx) 934 931 return -ENOMEM; 935 932 933 + ctx->dev = dev; 934 + 936 935 ret = fimd_get_platform_data(ctx, dev); 937 936 if (ret) 938 937 return ret; ··· 968 963 init_waitqueue_head(&ctx->wait_vsync_queue); 969 964 atomic_set(&ctx->wait_vsync_event, 0); 970 965 966 + fimd_manager.ctx = ctx; 967 + 971 968 subdrv = &ctx->subdrv; 972 969 973 970 subdrv->dev = dev; ··· 979 972 980 973 mutex_init(&ctx->lock); 981 974 982 - platform_set_drvdata(pdev, ctx); 975 + platform_set_drvdata(pdev, &fimd_manager); 983 976 984 977 pm_runtime_enable(dev); 985 978 pm_runtime_get_sync(dev); ··· 995 988 static int fimd_remove(struct platform_device *pdev) 996 989 { 997 990 struct device *dev = &pdev->dev; 998 - struct fimd_context *ctx = platform_get_drvdata(pdev); 991 + struct exynos_drm_manager *mgr = platform_get_drvdata(pdev); 992 + struct fimd_context *ctx = mgr->ctx; 999 993 1000 994 exynos_drm_subdrv_unregister(&ctx->subdrv); 1001 995 ··· 1015 1007 #ifdef CONFIG_PM_SLEEP 1016 1008 static int fimd_suspend(struct device *dev) 1017 1009 { 1018 - struct fimd_context *ctx = get_fimd_context(dev); 1010 + struct exynos_drm_manager *mgr = get_fimd_manager(dev); 1019 1011 1020 1012 /* 1021 1013 * do not use pm_runtime_suspend(). if pm_runtime_suspend() is ··· 1023 1015 * because the usage_count of pm runtime is more than 1. 1024 1016 */ 1025 1017 if (!pm_runtime_suspended(dev)) 1026 - return fimd_activate(ctx, false); 1018 + return fimd_activate(mgr, false); 1027 1019 1028 1020 return 0; 1029 1021 } 1030 1022 1031 1023 static int fimd_resume(struct device *dev) 1032 1024 { 1033 - struct fimd_context *ctx = get_fimd_context(dev); 1025 + struct exynos_drm_manager *mgr = get_fimd_manager(dev); 1034 1026 1035 1027 /* 1036 1028 * if entered to sleep when lcd panel was on, the usage_count ··· 1040 1032 if (!pm_runtime_suspended(dev)) { 1041 1033 int ret; 1042 1034 1043 - ret = fimd_activate(ctx, true); 1035 + ret = fimd_activate(mgr, true); 1044 1036 if (ret < 0) 1045 1037 return ret; 1046 1038 ··· 1050 1042 * registers but in case of sleep wakeup, it's not. 1051 1043 * so fimd_apply function should be called at here. 1052 1044 */ 1053 - fimd_apply(dev); 1045 + fimd_apply(mgr); 1054 1046 } 1055 1047 1056 1048 return 0; ··· 1060 1052 #ifdef CONFIG_PM_RUNTIME 1061 1053 static int fimd_runtime_suspend(struct device *dev) 1062 1054 { 1063 - struct fimd_context *ctx = get_fimd_context(dev); 1055 + struct exynos_drm_manager *mgr = get_fimd_manager(dev); 1064 1056 1065 - return fimd_activate(ctx, false); 1057 + return fimd_activate(mgr, false); 1066 1058 } 1067 1059 1068 1060 static int fimd_runtime_resume(struct device *dev) 1069 1061 { 1070 - struct fimd_context *ctx = get_fimd_context(dev); 1062 + struct exynos_drm_manager *mgr = get_fimd_manager(dev); 1071 1063 1072 - return fimd_activate(ctx, true); 1064 + return fimd_activate(mgr, true); 1073 1065 } 1074 1066 #endif 1075 1067
+40 -32
drivers/gpu/drm/exynos/exynos_drm_hdmi.c
··· 129 129 130 130 return NULL; 131 131 } 132 - 133 - static int drm_hdmi_check_mode(struct device *dev, 132 + static int drm_hdmi_check_mode_ctx(struct drm_hdmi_context *ctx, 134 133 struct drm_display_mode *mode) 135 134 { 136 - struct drm_hdmi_context *ctx = to_context(dev); 137 135 int ret = 0; 138 136 139 137 /* ··· 149 151 return hdmi_ops->check_mode(ctx->hdmi_ctx->ctx, mode); 150 152 151 153 return 0; 154 + } 155 + 156 + static int drm_hdmi_check_mode(struct device *dev, 157 + struct drm_display_mode *mode) 158 + { 159 + struct drm_hdmi_context *ctx = to_context(dev); 160 + 161 + return drm_hdmi_check_mode_ctx(ctx, mode); 152 162 } 153 163 154 164 static int drm_hdmi_power_on(struct device *dev, int mode) ··· 178 172 .power_on = drm_hdmi_power_on, 179 173 }; 180 174 181 - static int drm_hdmi_enable_vblank(struct device *subdrv_dev) 175 + static int drm_hdmi_enable_vblank(struct exynos_drm_manager *mgr) 182 176 { 183 - struct drm_hdmi_context *ctx = to_context(subdrv_dev); 177 + struct drm_hdmi_context *ctx = mgr->ctx; 184 178 struct exynos_drm_subdrv *subdrv = &ctx->subdrv; 185 179 struct exynos_drm_manager *manager = subdrv->manager; 186 180 ··· 191 185 return 0; 192 186 } 193 187 194 - static void drm_hdmi_disable_vblank(struct device *subdrv_dev) 188 + static void drm_hdmi_disable_vblank(struct exynos_drm_manager *mgr) 195 189 { 196 - struct drm_hdmi_context *ctx = to_context(subdrv_dev); 190 + struct drm_hdmi_context *ctx = mgr->ctx; 197 191 198 192 if (mixer_ops && mixer_ops->disable_vblank) 199 193 return mixer_ops->disable_vblank(ctx->mixer_ctx->ctx); 200 194 } 201 195 202 - static void drm_hdmi_wait_for_vblank(struct device *subdrv_dev) 196 + static void drm_hdmi_wait_for_vblank(struct exynos_drm_manager *mgr) 203 197 { 204 - struct drm_hdmi_context *ctx = to_context(subdrv_dev); 198 + struct drm_hdmi_context *ctx = mgr->ctx; 205 199 206 200 if (mixer_ops && mixer_ops->wait_for_vblank) 207 201 mixer_ops->wait_for_vblank(ctx->mixer_ctx->ctx); 208 202 } 209 203 210 - static void drm_hdmi_mode_fixup(struct device *subdrv_dev, 204 + static void drm_hdmi_mode_fixup(struct exynos_drm_manager *mgr, 211 205 struct drm_connector *connector, 212 206 const struct drm_display_mode *mode, 213 207 struct drm_display_mode *adjusted_mode) 214 208 { 209 + struct drm_hdmi_context *ctx = mgr->ctx; 215 210 struct drm_display_mode *m; 216 211 int mode_ok; 217 212 218 213 drm_mode_set_crtcinfo(adjusted_mode, 0); 219 214 220 - mode_ok = drm_hdmi_check_mode(subdrv_dev, adjusted_mode); 215 + mode_ok = drm_hdmi_check_mode_ctx(ctx, adjusted_mode); 221 216 222 217 /* just return if user desired mode exists. */ 223 218 if (mode_ok == 0) ··· 229 222 * to adjusted_mode. 230 223 */ 231 224 list_for_each_entry(m, &connector->modes, head) { 232 - mode_ok = drm_hdmi_check_mode(subdrv_dev, m); 225 + mode_ok = drm_hdmi_check_mode_ctx(ctx, m); 233 226 234 227 if (mode_ok == 0) { 235 228 struct drm_mode_object base; ··· 252 245 } 253 246 } 254 247 255 - static void drm_hdmi_mode_set(struct device *subdrv_dev, void *mode) 248 + static void drm_hdmi_mode_set(struct exynos_drm_manager *mgr, void *mode) 256 249 { 257 - struct drm_hdmi_context *ctx = to_context(subdrv_dev); 250 + struct drm_hdmi_context *ctx = mgr->ctx; 258 251 259 252 if (hdmi_ops && hdmi_ops->mode_set) 260 253 hdmi_ops->mode_set(ctx->hdmi_ctx->ctx, mode); 261 254 } 262 255 263 - static void drm_hdmi_get_max_resol(struct device *subdrv_dev, 256 + static void drm_hdmi_get_max_resol(struct exynos_drm_manager *mgr, 264 257 unsigned int *width, unsigned int *height) 265 258 { 266 - struct drm_hdmi_context *ctx = to_context(subdrv_dev); 259 + struct drm_hdmi_context *ctx = mgr->ctx; 267 260 268 261 if (hdmi_ops && hdmi_ops->get_max_resol) 269 262 hdmi_ops->get_max_resol(ctx->hdmi_ctx->ctx, width, height); 270 263 } 271 264 272 - static void drm_hdmi_commit(struct device *subdrv_dev) 265 + static void drm_hdmi_commit(struct exynos_drm_manager *mgr) 273 266 { 274 - struct drm_hdmi_context *ctx = to_context(subdrv_dev); 267 + struct drm_hdmi_context *ctx = mgr->ctx; 275 268 276 269 if (hdmi_ops && hdmi_ops->commit) 277 270 hdmi_ops->commit(ctx->hdmi_ctx->ctx); 278 271 } 279 272 280 - static int drm_hdmi_mgr_initialize(struct device *subdrv_dev, 281 - struct drm_device *drm_dev) 273 + static int drm_hdmi_mgr_initialize(struct exynos_drm_manager *mgr, struct drm_device *drm_dev) 282 274 { 283 - struct drm_hdmi_context *ctx = to_context(subdrv_dev); 275 + struct drm_hdmi_context *ctx = mgr->ctx; 284 276 int ret = 0; 285 277 286 278 if (mixer_ops && mixer_ops->initialize) ··· 291 285 return ret; 292 286 } 293 287 294 - static void drm_hdmi_dpms(struct device *subdrv_dev, int mode) 288 + static void drm_hdmi_dpms(struct exynos_drm_manager *mgr, int mode) 295 289 { 296 - struct drm_hdmi_context *ctx = to_context(subdrv_dev); 290 + struct drm_hdmi_context *ctx = mgr->ctx; 297 291 298 292 if (mixer_ops && mixer_ops->dpms) 299 293 mixer_ops->dpms(ctx->mixer_ctx->ctx, mode); ··· 302 296 hdmi_ops->dpms(ctx->hdmi_ctx->ctx, mode); 303 297 } 304 298 305 - static void drm_hdmi_apply(struct device *subdrv_dev) 299 + static void drm_hdmi_apply(struct exynos_drm_manager *mgr) 306 300 { 307 - struct drm_hdmi_context *ctx = to_context(subdrv_dev); 301 + struct drm_hdmi_context *ctx = mgr->ctx; 308 302 int i; 309 303 310 304 for (i = 0; i < MIXER_WIN_NR; i++) { ··· 318 312 hdmi_ops->commit(ctx->hdmi_ctx->ctx); 319 313 } 320 314 321 - static void drm_mixer_win_mode_set(struct device *subdrv_dev, 322 - struct exynos_drm_overlay *overlay) 315 + static void drm_mixer_win_mode_set(struct exynos_drm_manager *mgr, 316 + struct exynos_drm_overlay *overlay) 323 317 { 324 - struct drm_hdmi_context *ctx = to_context(subdrv_dev); 318 + struct drm_hdmi_context *ctx = mgr->ctx; 325 319 326 320 if (mixer_ops && mixer_ops->win_mode_set) 327 321 mixer_ops->win_mode_set(ctx->mixer_ctx->ctx, overlay); 328 322 } 329 323 330 - static void drm_mixer_win_commit(struct device *subdrv_dev, int zpos) 324 + static void drm_mixer_win_commit(struct exynos_drm_manager *mgr, int zpos) 331 325 { 332 - struct drm_hdmi_context *ctx = to_context(subdrv_dev); 326 + struct drm_hdmi_context *ctx = mgr->ctx; 333 327 int win = (zpos == DEFAULT_ZPOS) ? MIXER_DEFAULT_WIN : zpos; 334 328 335 329 if (win < 0 || win >= MIXER_WIN_NR) { ··· 343 337 ctx->enabled[win] = true; 344 338 } 345 339 346 - static void drm_mixer_win_disable(struct device *subdrv_dev, int zpos) 340 + static void drm_mixer_win_disable(struct exynos_drm_manager *mgr, int zpos) 347 341 { 348 - struct drm_hdmi_context *ctx = to_context(subdrv_dev); 342 + struct drm_hdmi_context *ctx = mgr->ctx; 349 343 int win = (zpos == DEFAULT_ZPOS) ? MIXER_DEFAULT_WIN : zpos; 350 344 351 345 if (win < 0 || win >= MIXER_WIN_NR) { ··· 430 424 ctx = devm_kzalloc(dev, sizeof(*ctx), GFP_KERNEL); 431 425 if (!ctx) 432 426 return -ENOMEM; 427 + 428 + hdmi_manager.ctx = ctx; 433 429 434 430 subdrv = &ctx->subdrv; 435 431
+46 -37
drivers/gpu/drm/exynos/exynos_drm_vidi.c
··· 28 28 /* vidi has totally three virtual windows. */ 29 29 #define WINDOWS_NR 3 30 30 31 - #define get_vidi_context(dev) platform_get_drvdata(to_platform_device(dev)) 31 + #define get_vidi_mgr(dev) platform_get_drvdata(to_platform_device(dev)) 32 32 33 33 struct vidi_win_data { 34 34 unsigned int offset_x; ··· 87 87 88 88 static bool vidi_display_is_connected(struct device *dev) 89 89 { 90 - struct vidi_context *ctx = get_vidi_context(dev); 90 + struct exynos_drm_manager *mgr = get_vidi_mgr(dev); 91 + struct vidi_context *ctx = mgr->ctx; 91 92 92 93 /* 93 94 * connection request would come from user side ··· 100 99 static struct edid *vidi_get_edid(struct device *dev, 101 100 struct drm_connector *connector) 102 101 { 103 - struct vidi_context *ctx = get_vidi_context(dev); 102 + struct exynos_drm_manager *mgr = get_vidi_mgr(dev); 103 + struct vidi_context *ctx = mgr->ctx; 104 104 struct edid *edid; 105 105 106 106 /* ··· 152 150 .power_on = vidi_display_power_on, 153 151 }; 154 152 155 - static void vidi_dpms(struct device *subdrv_dev, int mode) 153 + static void vidi_dpms(struct exynos_drm_manager *mgr, int mode) 156 154 { 157 - struct vidi_context *ctx = get_vidi_context(subdrv_dev); 155 + struct vidi_context *ctx = mgr->ctx; 158 156 159 157 DRM_DEBUG_KMS("%d\n", mode); 160 158 ··· 177 175 mutex_unlock(&ctx->lock); 178 176 } 179 177 180 - static void vidi_apply(struct device *subdrv_dev) 178 + static void vidi_apply(struct exynos_drm_manager *mgr) 181 179 { 182 - struct vidi_context *ctx = get_vidi_context(subdrv_dev); 183 - struct exynos_drm_manager *mgr = ctx->subdrv.manager; 180 + struct vidi_context *ctx = mgr->ctx; 184 181 struct exynos_drm_manager_ops *mgr_ops = mgr->ops; 185 182 struct vidi_win_data *win_data; 186 183 int i; ··· 187 186 for (i = 0; i < WINDOWS_NR; i++) { 188 187 win_data = &ctx->win_data[i]; 189 188 if (win_data->enabled && (mgr_ops && mgr_ops->win_commit)) 190 - mgr_ops->win_commit(subdrv_dev, i); 189 + mgr_ops->win_commit(mgr, i); 191 190 } 192 191 193 192 if (mgr_ops && mgr_ops->commit) 194 - mgr_ops->commit(subdrv_dev); 193 + mgr_ops->commit(mgr); 195 194 } 196 195 197 - static void vidi_commit(struct device *dev) 196 + static void vidi_commit(struct exynos_drm_manager *mgr) 198 197 { 199 - struct vidi_context *ctx = get_vidi_context(dev); 198 + struct vidi_context *ctx = mgr->ctx; 200 199 201 200 if (ctx->suspended) 202 201 return; 203 202 } 204 203 205 - static int vidi_enable_vblank(struct device *dev) 204 + static int vidi_enable_vblank(struct exynos_drm_manager *mgr) 206 205 { 207 - struct vidi_context *ctx = get_vidi_context(dev); 206 + struct vidi_context *ctx = mgr->ctx; 208 207 209 208 if (ctx->suspended) 210 209 return -EPERM; ··· 224 223 return 0; 225 224 } 226 225 227 - static void vidi_disable_vblank(struct device *dev) 226 + static void vidi_disable_vblank(struct exynos_drm_manager *mgr) 228 227 { 229 - struct vidi_context *ctx = get_vidi_context(dev); 228 + struct vidi_context *ctx = mgr->ctx; 230 229 231 230 if (ctx->suspended) 232 231 return; ··· 235 234 ctx->vblank_on = false; 236 235 } 237 236 238 - static void vidi_win_mode_set(struct device *dev, 239 - struct exynos_drm_overlay *overlay) 237 + static void vidi_win_mode_set(struct exynos_drm_manager *mgr, 238 + struct exynos_drm_overlay *overlay) 240 239 { 241 - struct vidi_context *ctx = get_vidi_context(dev); 240 + struct vidi_context *ctx = mgr->ctx; 242 241 struct vidi_win_data *win_data; 243 242 int win; 244 243 unsigned long offset; 245 244 246 245 if (!overlay) { 247 - dev_err(dev, "overlay is NULL\n"); 246 + DRM_ERROR("overlay is NULL\n"); 248 247 return; 249 248 } 250 249 ··· 288 287 overlay->fb_width, overlay->crtc_width); 289 288 } 290 289 291 - static void vidi_win_commit(struct device *dev, int zpos) 290 + static void vidi_win_commit(struct exynos_drm_manager *mgr, int zpos) 292 291 { 293 - struct vidi_context *ctx = get_vidi_context(dev); 292 + struct vidi_context *ctx = mgr->ctx; 294 293 struct vidi_win_data *win_data; 295 294 int win = zpos; 296 295 ··· 313 312 schedule_work(&ctx->work); 314 313 } 315 314 316 - static void vidi_win_disable(struct device *dev, int zpos) 315 + static void vidi_win_disable(struct exynos_drm_manager *mgr, int zpos) 317 316 { 318 - struct vidi_context *ctx = get_vidi_context(dev); 317 + struct vidi_context *ctx = mgr->ctx; 319 318 struct vidi_win_data *win_data; 320 319 int win = zpos; 321 320 ··· 402 401 /* TODO. */ 403 402 } 404 403 405 - static int vidi_power_on(struct vidi_context *ctx, bool enable) 404 + static int vidi_power_on(struct exynos_drm_manager *mgr, bool enable) 406 405 { 407 - struct exynos_drm_subdrv *subdrv = &ctx->subdrv; 408 - struct device *dev = subdrv->dev; 406 + struct vidi_context *ctx = mgr->ctx; 407 + 408 + DRM_DEBUG_KMS("%s\n", __FILE__); 409 + 410 + if (enable != false && enable != true) 411 + return -EINVAL; 409 412 410 413 if (enable) { 411 414 ctx->suspended = false; 412 415 413 416 /* if vblank was enabled status, enable it again. */ 414 417 if (test_and_clear_bit(0, &ctx->irq_flags)) 415 - vidi_enable_vblank(dev); 418 + vidi_enable_vblank(mgr); 416 419 417 - vidi_apply(dev); 420 + vidi_apply(mgr); 418 421 } else { 419 422 ctx->suspended = true; 420 423 } ··· 430 425 struct device_attribute *attr, char *buf) 431 426 { 432 427 int rc; 433 - struct vidi_context *ctx = get_vidi_context(dev); 428 + struct exynos_drm_manager *mgr = get_vidi_mgr(dev); 429 + struct vidi_context *ctx = mgr->ctx; 434 430 435 431 mutex_lock(&ctx->lock); 436 432 ··· 446 440 struct device_attribute *attr, 447 441 const char *buf, size_t len) 448 442 { 449 - struct vidi_context *ctx = get_vidi_context(dev); 443 + struct exynos_drm_manager *mgr = get_vidi_mgr(dev); 444 + struct vidi_context *ctx = mgr->ctx; 450 445 int ret; 451 446 452 447 ret = kstrtoint(buf, 0, &ctx->connected); ··· 502 495 display_ops = manager->display_ops; 503 496 504 497 if (display_ops->type == EXYNOS_DISPLAY_TYPE_VIDI) { 505 - ctx = get_vidi_context(manager->dev); 498 + ctx = manager->ctx; 506 499 break; 507 500 } 508 501 } ··· 561 554 562 555 INIT_WORK(&ctx->work, vidi_fake_vblank_handler); 563 556 557 + vidi_manager.ctx = ctx; 558 + 564 559 subdrv = &ctx->subdrv; 565 560 subdrv->dev = dev; 566 561 subdrv->manager = &vidi_manager; ··· 571 562 572 563 mutex_init(&ctx->lock); 573 564 574 - platform_set_drvdata(pdev, ctx); 565 + platform_set_drvdata(pdev, &vidi_manager); 575 566 576 567 ret = device_create_file(dev, &dev_attr_connection); 577 568 if (ret < 0) ··· 599 590 #ifdef CONFIG_PM_SLEEP 600 591 static int vidi_suspend(struct device *dev) 601 592 { 602 - struct vidi_context *ctx = get_vidi_context(dev); 593 + struct exynos_drm_manager *mgr = get_vidi_mgr(dev); 603 594 604 - return vidi_power_on(ctx, false); 595 + return vidi_power_on(mgr, false); 605 596 } 606 597 607 598 static int vidi_resume(struct device *dev) 608 599 { 609 - struct vidi_context *ctx = get_vidi_context(dev); 600 + struct exynos_drm_manager *mgr = get_vidi_mgr(dev); 610 601 611 - return vidi_power_on(ctx, true); 602 + return vidi_power_on(mgr, true); 612 603 } 613 604 #endif 614 605