> void exynos_drm_encoder_plane_enable(struct drm_encoder *encoder, void > *data) > @@ -495,7 +495,7 @@ void exynos_drm_encoder_plane_enable(struct > drm_encoder *encoder, void *data) > zpos = *(int *)data; > > if (manager_ops && manager_ops->win_enable) > - manager_ops->win_enable(manager->dev, zpos); > + manager_ops->win_enable(manager->ctx, zpos); > } > > void exynos_drm_encoder_plane_disable(struct drm_encoder *encoder, void > *data) > @@ -509,5 +509,5 @@ void exynos_drm_encoder_plane_disable(struct > drm_encoder *encoder, void *data) > zpos = *(int *)data; > > if (manager_ops && manager_ops->win_disable) > - manager_ops->win_disable(manager->dev, zpos); > + manager_ops->win_disable(manager->ctx, zpos); > } > diff --git a/drivers/gpu/drm/exynos/exynos_drm_fimd.c > b/drivers/gpu/drm/exynos/exynos_drm_fimd.c > index 90fcd6f..9c2720a 100644 > --- a/drivers/gpu/drm/exynos/exynos_drm_fimd.c > +++ b/drivers/gpu/drm/exynos/exynos_drm_fimd.c > @@ -106,6 +106,7 @@ struct fimd_win_data { > > struct fimd_context { > struct exynos_drm_subdrv subdrv; > + struct device *dev; Where device object is set to ctx->dev? And we already have device object in subdrv. And why did you add dev? And you are making driver callbacks to be called with its own context. Why framework should know the context of each driver? The framework knows the device object of each device driver since the sub driver of each device driver is registered to the framework. And the device driver can get its own context from the device object driver-internally. The framework should call some callbacks of each device driver _with_device_object_, and this way is more generic. The context is a_thing_only_for_the_device_driver. > struct drm_device *drm_dev; > int irq; > struct drm_crtc *crtc; > @@ -182,16 +183,15 @@ static struct exynos_drm_display_ops > fimd_display_ops = { > .power_on = fimd_display_power_on, > }; > > -static void fimd_win_mode_set(struct device *dev, > - struct exynos_drm_overlay *overlay) > +static void fimd_win_mode_set(void *in_ctx, struct exynos_drm_overlay > *overlay) > { > - struct fimd_context *ctx = get_fimd_context(dev); > + struct fimd_context *ctx = in_ctx; > struct fimd_win_data *win_data; > int win; > unsigned long offset; > > if (!overlay) { > - dev_err(dev, "overlay is NULL\n"); > + DRM_ERROR("overlay is NULL\n"); > return; > } > > @@ -231,9 +231,8 @@ static void fimd_win_mode_set(struct device *dev, > overlay->fb_width, overlay->crtc_width); > } > > -static void fimd_win_set_pixfmt(struct device *dev, unsigned int win) > +static void fimd_win_set_pixfmt(struct fimd_context *ctx, unsigned int > win) > { > - struct fimd_context *ctx = get_fimd_context(dev); > struct fimd_win_data *win_data = &ctx->win_data[win]; > unsigned long val; > > @@ -289,9 +288,8 @@ static void fimd_win_set_pixfmt(struct device *dev, > unsigned int win) > writel(val, ctx->regs + WINCON(win)); > } > > -static void fimd_win_set_colkey(struct device *dev, unsigned int win) > +static void fimd_win_set_colkey(struct fimd_context *ctx, unsigned int > win) > { > - struct fimd_context *ctx = get_fimd_context(dev); > unsigned int keycon0 = 0, keycon1 = 0; > > keycon0 = ~(WxKEYCON0_KEYBL_EN | WxKEYCON0_KEYEN_F | > @@ -330,9 +328,9 @@ static void fimd_shadow_protect_win(struct > fimd_context *ctx, > writel(val, ctx->regs + reg); > } > > -static void fimd_win_commit(struct device *dev, int zpos) > +static void fimd_win_commit(void *in_ctx, int zpos) > { > - struct fimd_context *ctx = get_fimd_context(dev); > + struct fimd_context *ctx = in_ctx; > struct fimd_win_data *win_data; > int win = zpos; > unsigned long val, alpha, size; > @@ -427,11 +425,11 @@ static void fimd_win_commit(struct device *dev, int > zpos) > DRM_DEBUG_KMS("osd size = 0x%x\n", (unsigned int)val); > } > > - fimd_win_set_pixfmt(dev, win); > + fimd_win_set_pixfmt(ctx, win); > > /* hardware window 0 doesn't support color key. */ > if (win != 0) > - fimd_win_set_colkey(dev, win); > + fimd_win_set_colkey(ctx, win); > > /* wincon */ > val = readl(ctx->regs + WINCON(win)); > @@ -450,9 +448,9 @@ static void fimd_win_commit(struct device *dev, int > zpos) > win_data->enabled = true; > } > > -static void fimd_win_disable(struct device *dev, int zpos) > +static void fimd_win_disable(void *in_ctx, int zpos) > { > - struct fimd_context *ctx = get_fimd_context(dev); > + struct fimd_context *ctx = in_ctx; > struct fimd_win_data *win_data; > int win = zpos; > u32 val; > @@ -491,19 +489,18 @@ static void fimd_win_disable(struct device *dev, int > zpos) > win_data->enabled = false; > } > > -static int fimd_mgr_initialize(struct device *subdrv_dev, > - struct drm_device *drm_dev) > +static int fimd_mgr_initialize(void *in_ctx, struct drm_device *drm_dev) > { > - struct fimd_context *ctx = get_fimd_context(subdrv_dev); > + struct fimd_context *ctx = in_ctx; > > ctx->drm_dev = drm_dev; > > return 0; > } > > -static void fimd_dpms(struct device *subdrv_dev, int mode) > +static void fimd_dpms(void *in_ctx, int mode) > { > - struct fimd_context *ctx = get_fimd_context(subdrv_dev); > + struct fimd_context *ctx = in_ctx; > > DRM_DEBUG_KMS("%d\n", mode); > > @@ -518,13 +515,13 @@ static void fimd_dpms(struct device *subdrv_dev, int > mode) > * clk_enable could be called double time. > */ > if (ctx->suspended) > - pm_runtime_get_sync(subdrv_dev); > + pm_runtime_get_sync(ctx->dev); Maybe invalid memory access to ctx->dev. So Shoulnd't it ctx->subdrv.dev? > break; > case DRM_MODE_DPMS_STANDBY: > case DRM_MODE_DPMS_SUSPEND: > case DRM_MODE_DPMS_OFF: > if (!ctx->suspended) > - pm_runtime_put_sync(subdrv_dev); > + pm_runtime_put_sync(ctx->dev); Ditto > break; > default: > DRM_DEBUG_KMS("unspecified mode %d\n", mode); > @@ -534,9 +531,9 @@ static void fimd_dpms(struct device *subdrv_dev, int > mode) > mutex_unlock(&ctx->lock); > } > > -static void fimd_apply(struct device *subdrv_dev) > +static void fimd_apply(void *in_ctx) > { > - struct fimd_context *ctx = get_fimd_context(subdrv_dev); > + struct fimd_context *ctx = in_ctx; > struct exynos_drm_manager *mgr = ctx->subdrv.manager; > struct exynos_drm_manager_ops *mgr_ops = mgr->ops; > struct fimd_win_data *win_data; > @@ -545,16 +542,16 @@ static void fimd_apply(struct device *subdrv_dev) > for (i = 0; i < WINDOWS_NR; i++) { > win_data = &ctx->win_data[i]; > if (win_data->enabled && (mgr_ops && mgr_ops->win_commit)) > - mgr_ops->win_commit(subdrv_dev, i); > + mgr_ops->win_commit(ctx, i); > } > > if (mgr_ops && mgr_ops->commit) > - mgr_ops->commit(subdrv_dev); > + mgr_ops->commit(ctx); > } > > -static void fimd_commit(struct device *dev) > +static void fimd_commit(void *in_ctx) > { > - struct fimd_context *ctx = get_fimd_context(dev); > + struct fimd_context *ctx = in_ctx; > struct exynos_drm_panel_info *panel = &ctx->panel; > struct videomode *vm = &panel->vm; > struct fimd_driver_data *driver_data; > @@ -608,9 +605,9 @@ static void fimd_commit(struct device *dev) > writel(val, ctx->regs + VIDCON0); > } > > -static int fimd_enable_vblank(struct device *dev) > +static int fimd_enable_vblank(void *in_ctx) > { > - struct fimd_context *ctx = get_fimd_context(dev); > + struct fimd_context *ctx = in_ctx; > u32 val; > > if (ctx->suspended) > @@ -633,9 +630,9 @@ static int fimd_enable_vblank(struct device *dev) > return 0; > } > > -static void fimd_disable_vblank(struct device *dev) > +static void fimd_disable_vblank(void *in_ctx) > { > - struct fimd_context *ctx = get_fimd_context(dev); > + struct fimd_context *ctx = in_ctx; > u32 val; > > if (ctx->suspended) > @@ -651,9 +648,9 @@ static void fimd_disable_vblank(struct device *dev) > } > } > > -static void fimd_wait_for_vblank(struct device *dev) > +static void fimd_wait_for_vblank(void *in_ctx) > { > - struct fimd_context *ctx = get_fimd_context(dev); > + struct fimd_context *ctx = in_ctx; > > if (ctx->suspended) > return; > @@ -845,9 +842,9 @@ static void fimd_window_suspend(struct device *dev) > for (i = 0; i < WINDOWS_NR; i++) { > win_data = &ctx->win_data[i]; > win_data->resume = win_data->enabled; > - fimd_win_disable(dev, i); > + fimd_win_disable(ctx, i); > } > - fimd_wait_for_vblank(dev); > + fimd_wait_for_vblank(ctx); > } > > static void fimd_window_resume(struct device *dev) > @@ -963,6 +960,8 @@ static int fimd_probe(struct platform_device *pdev) > DRM_INIT_WAITQUEUE(&ctx->wait_vsync_queue); > atomic_set(&ctx->wait_vsync_event, 0); > > + fimd_manager.ctx = ctx; > + > subdrv = &ctx->subdrv; > > subdrv->dev = dev; > @@ -1042,7 +1041,7 @@ static int fimd_resume(struct device *dev) > * registers but in case of sleep wakeup, it's not. > * so fimd_apply function should be called at here. > */ > - fimd_apply(dev); > + fimd_apply(ctx); > } > > return 0; > diff --git a/drivers/gpu/drm/exynos/exynos_drm_hdmi.c > b/drivers/gpu/drm/exynos/exynos_drm_hdmi.c > index aebcc0e..cddb0c8 100644 > --- a/drivers/gpu/drm/exynos/exynos_drm_hdmi.c > +++ b/drivers/gpu/drm/exynos/exynos_drm_hdmi.c > @@ -129,11 +129,9 @@ static struct edid *drm_hdmi_get_edid(struct device > *dev, > > return NULL; > } > - > -static int drm_hdmi_check_mode(struct device *dev, > +static int drm_hdmi_check_mode_ctx(struct drm_hdmi_context *ctx, > struct drm_display_mode *mode) > { > - struct drm_hdmi_context *ctx = to_context(dev); > int ret = 0; > > /* > @@ -153,6 +151,14 @@ static int drm_hdmi_check_mode(struct device *dev, > return 0; > } > > +static int drm_hdmi_check_mode(struct device *dev, > + struct drm_display_mode *mode) > +{ > + struct drm_hdmi_context *ctx = to_context(dev); > + > + return drm_hdmi_check_mode_ctx(ctx, mode); > +} > + > static int drm_hdmi_power_on(struct device *dev, int mode) > { > struct drm_hdmi_context *ctx = to_context(dev); > @@ -172,9 +178,9 @@ static struct exynos_drm_display_ops > drm_hdmi_display_ops = { > .power_on = drm_hdmi_power_on, > }; > > -static int drm_hdmi_enable_vblank(struct device *subdrv_dev) > +static int drm_hdmi_enable_vblank(void *in_ctx) > { > - struct drm_hdmi_context *ctx = to_context(subdrv_dev); > + struct drm_hdmi_context *ctx = in_ctx; > struct exynos_drm_subdrv *subdrv = &ctx->subdrv; > struct exynos_drm_manager *manager = subdrv->manager; > > @@ -185,33 +191,33 @@ static int drm_hdmi_enable_vblank(struct device > *subdrv_dev) > return 0; > } > > -static void drm_hdmi_disable_vblank(struct device *subdrv_dev) > +static void drm_hdmi_disable_vblank(void *in_ctx) > { > - struct drm_hdmi_context *ctx = to_context(subdrv_dev); > + struct drm_hdmi_context *ctx = in_ctx; > > if (mixer_ops && mixer_ops->disable_vblank) > return mixer_ops->disable_vblank(ctx->mixer_ctx->ctx); > } > > -static void drm_hdmi_wait_for_vblank(struct device *subdrv_dev) > +static void drm_hdmi_wait_for_vblank(void *in_ctx) > { > - struct drm_hdmi_context *ctx = to_context(subdrv_dev); > + struct drm_hdmi_context *ctx = in_ctx; > > if (mixer_ops && mixer_ops->wait_for_vblank) > mixer_ops->wait_for_vblank(ctx->mixer_ctx->ctx); > } > > -static void drm_hdmi_mode_fixup(struct device *subdrv_dev, > - struct drm_connector *connector, > +static void drm_hdmi_mode_fixup(void *in_ctx, struct drm_connector > *connector, > const struct drm_display_mode *mode, > struct drm_display_mode *adjusted_mode) > { > + struct drm_hdmi_context *ctx = in_ctx; > struct drm_display_mode *m; > int mode_ok; > > drm_mode_set_crtcinfo(adjusted_mode, 0); > > - mode_ok = drm_hdmi_check_mode(subdrv_dev, adjusted_mode); > + mode_ok = drm_hdmi_check_mode_ctx(ctx, adjusted_mode); > > /* just return if user desired mode exists. */ > if (mode_ok == 0) > @@ -222,7 +228,7 @@ static void drm_hdmi_mode_fixup(struct device > *subdrv_dev, > * to adjusted_mode. > */ > list_for_each_entry(m, &connector->modes, head) { > - mode_ok = drm_hdmi_check_mode(subdrv_dev, m); > + mode_ok = drm_hdmi_check_mode_ctx(ctx, m); > > if (mode_ok == 0) { > struct drm_mode_object base; > @@ -245,35 +251,34 @@ static void drm_hdmi_mode_fixup(struct device > *subdrv_dev, > } > } > > -static void drm_hdmi_mode_set(struct device *subdrv_dev, void *mode) > +static void drm_hdmi_mode_set(void *in_ctx, void *mode) > { > - struct drm_hdmi_context *ctx = to_context(subdrv_dev); > + struct drm_hdmi_context *ctx = in_ctx; > > if (hdmi_ops && hdmi_ops->mode_set) > hdmi_ops->mode_set(ctx->hdmi_ctx->ctx, mode); > } > > -static void drm_hdmi_get_max_resol(struct device *subdrv_dev, > - unsigned int *width, unsigned int *height) > +static void drm_hdmi_get_max_resol(void *in_ctx, unsigned int *width, > + unsigned int *height) > { > - struct drm_hdmi_context *ctx = to_context(subdrv_dev); > + struct drm_hdmi_context *ctx = in_ctx; > > if (hdmi_ops && hdmi_ops->get_max_resol) > hdmi_ops->get_max_resol(ctx->hdmi_ctx->ctx, width, height); > } > > -static void drm_hdmi_commit(struct device *subdrv_dev) > +static void drm_hdmi_commit(void *in_ctx) > { > - struct drm_hdmi_context *ctx = to_context(subdrv_dev); > + struct drm_hdmi_context *ctx = in_ctx; > > if (hdmi_ops && hdmi_ops->commit) > hdmi_ops->commit(ctx->hdmi_ctx->ctx); > } > > -static int drm_hdmi_mgr_initialize(struct device *subdrv_dev, > - struct drm_device *drm_dev) > +static int drm_hdmi_mgr_initialize(void *in_ctx, struct drm_device > *drm_dev) > { > - struct drm_hdmi_context *ctx = to_context(subdrv_dev); > + struct drm_hdmi_context *ctx = in_ctx; > int ret = 0; > > if (mixer_ops && mixer_ops->initialize) > @@ -285,9 +290,9 @@ static int drm_hdmi_mgr_initialize(struct device > *subdrv_dev, > return ret; > } > > -static void drm_hdmi_dpms(struct device *subdrv_dev, int mode) > +static void drm_hdmi_dpms(void *in_ctx, int mode) > { > - struct drm_hdmi_context *ctx = to_context(subdrv_dev); > + struct drm_hdmi_context *ctx = in_ctx; > > if (mixer_ops && mixer_ops->dpms) > mixer_ops->dpms(ctx->mixer_ctx->ctx, mode); > @@ -296,9 +301,9 @@ static void drm_hdmi_dpms(struct device *subdrv_dev, > int mode) > hdmi_ops->dpms(ctx->hdmi_ctx->ctx, mode); > } > > -static void drm_hdmi_apply(struct device *subdrv_dev) > +static void drm_hdmi_apply(void *in_ctx) > { > - struct drm_hdmi_context *ctx = to_context(subdrv_dev); > + struct drm_hdmi_context *ctx = in_ctx; > int i; > > for (i = 0; i < MIXER_WIN_NR; i++) { > @@ -312,18 +317,18 @@ static void drm_hdmi_apply(struct device *subdrv_dev) > hdmi_ops->commit(ctx->hdmi_ctx->ctx); > } > > -static void drm_mixer_win_mode_set(struct device *subdrv_dev, > - struct exynos_drm_overlay *overlay) > +static void drm_mixer_win_mode_set(void *in_ctx, > + struct exynos_drm_overlay *overlay) > { > - struct drm_hdmi_context *ctx = to_context(subdrv_dev); > + struct drm_hdmi_context *ctx = in_ctx; > > if (mixer_ops && mixer_ops->win_mode_set) > mixer_ops->win_mode_set(ctx->mixer_ctx->ctx, overlay); > } > > -static void drm_mixer_win_commit(struct device *subdrv_dev, int zpos) > +static void drm_mixer_win_commit(void *in_ctx, int zpos) > { > - struct drm_hdmi_context *ctx = to_context(subdrv_dev); > + struct drm_hdmi_context *ctx = in_ctx; > int win = (zpos == DEFAULT_ZPOS) ? MIXER_DEFAULT_WIN : zpos; > > if (win < 0 || win >= MIXER_WIN_NR) { > @@ -337,9 +342,9 @@ static void drm_mixer_win_commit(struct device > *subdrv_dev, int zpos) > ctx->enabled[win] = true; > } > > -static void drm_mixer_win_disable(struct device *subdrv_dev, int zpos) > +static void drm_mixer_win_disable(void *in_ctx, int zpos) > { > - struct drm_hdmi_context *ctx = to_context(subdrv_dev); > + struct drm_hdmi_context *ctx = in_ctx; > int win = (zpos == DEFAULT_ZPOS) ? MIXER_DEFAULT_WIN : zpos; > > if (win < 0 || win >= MIXER_WIN_NR) { > @@ -425,6 +430,8 @@ static int exynos_drm_hdmi_probe(struct > platform_device *pdev) > if (!ctx) > return -ENOMEM; > > + hdmi_manager.ctx = ctx; > + > subdrv = &ctx->subdrv; > > subdrv->dev = dev; > diff --git a/drivers/gpu/drm/exynos/exynos_drm_vidi.c > b/drivers/gpu/drm/exynos/exynos_drm_vidi.c > index 15a97ce..a583a74 100644 > --- a/drivers/gpu/drm/exynos/exynos_drm_vidi.c > +++ b/drivers/gpu/drm/exynos/exynos_drm_vidi.c > @@ -152,9 +152,9 @@ static struct exynos_drm_display_ops vidi_display_ops > = { > .power_on = vidi_display_power_on, > }; > > -static void vidi_dpms(struct device *subdrv_dev, int mode) > +static void vidi_dpms(void *in_ctx, int mode) > { > - struct vidi_context *ctx = get_vidi_context(subdrv_dev); > + struct vidi_context *ctx = in_ctx; > > DRM_DEBUG_KMS("%d\n", mode); > > @@ -177,9 +177,9 @@ static void vidi_dpms(struct device *subdrv_dev, int > mode) > mutex_unlock(&ctx->lock); > } > > -static void vidi_apply(struct device *subdrv_dev) > +static void vidi_apply(void *in_ctx) > { > - struct vidi_context *ctx = get_vidi_context(subdrv_dev); > + struct vidi_context *ctx = in_ctx; > struct exynos_drm_manager *mgr = ctx->subdrv.manager; > struct exynos_drm_manager_ops *mgr_ops = mgr->ops; > struct vidi_win_data *win_data; > @@ -188,24 +188,24 @@ static void vidi_apply(struct device *subdrv_dev) > for (i = 0; i < WINDOWS_NR; i++) { > win_data = &ctx->win_data[i]; > if (win_data->enabled && (mgr_ops && mgr_ops->win_commit)) > - mgr_ops->win_commit(subdrv_dev, i); > + mgr_ops->win_commit(ctx, i); > } > > if (mgr_ops && mgr_ops->commit) > - mgr_ops->commit(subdrv_dev); > + mgr_ops->commit(ctx); > } > > -static void vidi_commit(struct device *dev) > +static void vidi_commit(void *in_ctx) > { > - struct vidi_context *ctx = get_vidi_context(dev); > + struct vidi_context *ctx = in_ctx; > > if (ctx->suspended) > return; > } > > -static int vidi_enable_vblank(struct device *dev) > +static int vidi_enable_vblank(void *in_ctx) > { > - struct vidi_context *ctx = get_vidi_context(dev); > + struct vidi_context *ctx = in_ctx; > > if (ctx->suspended) > return -EPERM; > @@ -225,9 +225,9 @@ static int vidi_enable_vblank(struct device *dev) > return 0; > } > > -static void vidi_disable_vblank(struct device *dev) > +static void vidi_disable_vblank(void *in_ctx) > { > - struct vidi_context *ctx = get_vidi_context(dev); > + struct vidi_context *ctx = in_ctx; > > if (ctx->suspended) > return; > @@ -236,16 +236,15 @@ static void vidi_disable_vblank(struct device *dev) > ctx->vblank_on = false; > } > > -static void vidi_win_mode_set(struct device *dev, > - struct exynos_drm_overlay *overlay) > +static void vidi_win_mode_set(void *in_ctx, struct exynos_drm_overlay > *overlay) > { > - struct vidi_context *ctx = get_vidi_context(dev); > + struct vidi_context *ctx = in_ctx; > struct vidi_win_data *win_data; > int win; > unsigned long offset; > > if (!overlay) { > - dev_err(dev, "overlay is NULL\n"); > + DRM_ERROR("overlay is NULL\n"); > return; > } > > @@ -289,9 +288,9 @@ static void vidi_win_mode_set(struct device *dev, > overlay->fb_width, overlay->crtc_width); > } > > -static void vidi_win_commit(struct device *dev, int zpos) > +static void vidi_win_commit(void *in_ctx, int zpos) > { > - struct vidi_context *ctx = get_vidi_context(dev); > + struct vidi_context *ctx = in_ctx; > struct vidi_win_data *win_data; > int win = zpos; > > @@ -314,9 +313,9 @@ static void vidi_win_commit(struct device *dev, int > zpos) > schedule_work(&ctx->work); > } > > -static void vidi_win_disable(struct device *dev, int zpos) > +static void vidi_win_disable(void *in_ctx, int zpos) > { > - struct vidi_context *ctx = get_vidi_context(dev); > + struct vidi_context *ctx = in_ctx; > struct vidi_win_data *win_data; > int win = zpos; > > @@ -405,17 +404,19 @@ static void vidi_subdrv_remove(struct drm_device > *drm_dev, struct device *dev) > > static int vidi_power_on(struct vidi_context *ctx, bool enable) > { > - struct exynos_drm_subdrv *subdrv = &ctx->subdrv; > - struct device *dev = subdrv->dev; > + DRM_DEBUG_KMS("%s\n", __FILE__); > + > + if (enable != false && enable != true) > + return -EINVAL; > > if (enable) { > ctx->suspended = false; > > /* if vblank was enabled status, enable it again. */ > if (test_and_clear_bit(0, &ctx->irq_flags)) > - vidi_enable_vblank(dev); > + vidi_enable_vblank(ctx); > > - vidi_apply(dev); > + vidi_apply(ctx); > } else { > ctx->suspended = true; > } > -- > 1.8.4 _______________________________________________ dri-devel mailing list dri-devel@xxxxxxxxxxxxxxxxxxxxx http://lists.freedesktop.org/mailman/listinfo/dri-devel