Commit bb7704d6a6861cd17fc31e2fd6896d056b18aa47

Authored by Sean Paul
Committed by Inki Dae
1 parent 4551789fcf

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>

Showing 6 changed files with 180 additions and 153 deletions Side-by-side Diff

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