2011-10-04 04:19:01 -06:00
|
|
|
/* exynos_drm_core.c
|
|
|
|
*
|
|
|
|
* Copyright (c) 2011 Samsung Electronics Co., Ltd.
|
|
|
|
* Author:
|
|
|
|
* Inki Dae <inki.dae@samsung.com>
|
|
|
|
* Joonyoung Shim <jy0922.shim@samsung.com>
|
|
|
|
* Seung-Woo Kim <sw0312.kim@samsung.com>
|
|
|
|
*
|
2012-12-17 10:30:17 -07:00
|
|
|
* This program is free software; you can redistribute it and/or modify it
|
|
|
|
* under the terms of the GNU General Public License as published by the
|
|
|
|
* Free Software Foundation; either version 2 of the License, or (at your
|
|
|
|
* option) any later version.
|
2011-10-04 04:19:01 -06:00
|
|
|
*/
|
|
|
|
|
2012-10-02 11:01:07 -06:00
|
|
|
#include <drm/drmP.h>
|
2017-08-24 07:33:51 -06:00
|
|
|
|
2011-10-04 04:19:01 -06:00
|
|
|
#include "exynos_drm_drv.h"
|
2014-02-19 05:02:55 -07:00
|
|
|
#include "exynos_drm_crtc.h"
|
2011-10-04 04:19:01 -06:00
|
|
|
|
|
|
|
static LIST_HEAD(exynos_drm_subdrv_list);
|
|
|
|
|
2014-05-08 23:25:20 -06:00
|
|
|
int exynos_drm_subdrv_register(struct exynos_drm_subdrv *subdrv)
|
2014-02-19 05:02:55 -07:00
|
|
|
{
|
2014-05-08 23:25:20 -06:00
|
|
|
if (!subdrv)
|
|
|
|
return -EINVAL;
|
2014-02-19 05:02:55 -07:00
|
|
|
|
2014-05-08 23:25:20 -06:00
|
|
|
list_add_tail(&subdrv->list, &exynos_drm_subdrv_list);
|
2014-02-19 05:02:55 -07:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2014-05-08 23:25:20 -06:00
|
|
|
int exynos_drm_subdrv_unregister(struct exynos_drm_subdrv *subdrv)
|
2014-02-19 05:02:55 -07:00
|
|
|
{
|
2014-05-08 23:25:20 -06:00
|
|
|
if (!subdrv)
|
|
|
|
return -EINVAL;
|
2014-02-19 05:02:55 -07:00
|
|
|
|
2014-05-08 23:25:20 -06:00
|
|
|
list_del(&subdrv->list);
|
2014-02-19 05:02:55 -07:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2014-05-08 23:25:20 -06:00
|
|
|
int exynos_drm_device_subdrv_probe(struct drm_device *dev)
|
2011-10-04 04:19:01 -06:00
|
|
|
{
|
|
|
|
struct exynos_drm_subdrv *subdrv, *n;
|
|
|
|
int err;
|
|
|
|
|
|
|
|
if (!dev)
|
|
|
|
return -EINVAL;
|
|
|
|
|
|
|
|
list_for_each_entry_safe(subdrv, n, &exynos_drm_subdrv_list, list) {
|
2014-05-08 23:25:20 -06:00
|
|
|
if (subdrv->probe) {
|
|
|
|
subdrv->drm_dev = dev;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* this probe callback would be called by sub driver
|
|
|
|
* after setting of all resources to this sub driver,
|
|
|
|
* such as clock, irq and register map are done.
|
|
|
|
*/
|
|
|
|
err = subdrv->probe(dev, subdrv->dev);
|
|
|
|
if (err) {
|
|
|
|
DRM_DEBUG("exynos drm subdrv probe failed.\n");
|
|
|
|
list_del(&subdrv->list);
|
|
|
|
continue;
|
|
|
|
}
|
2012-08-16 22:23:25 -06:00
|
|
|
}
|
2011-10-04 04:19:01 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2014-05-08 23:25:20 -06:00
|
|
|
int exynos_drm_device_subdrv_remove(struct drm_device *dev)
|
2011-10-04 04:19:01 -06:00
|
|
|
{
|
|
|
|
struct exynos_drm_subdrv *subdrv;
|
|
|
|
|
2012-03-16 03:47:08 -06:00
|
|
|
if (!dev) {
|
2011-10-04 04:19:01 -06:00
|
|
|
WARN(1, "Unexpected drm device unregister!\n");
|
|
|
|
return -EINVAL;
|
|
|
|
}
|
|
|
|
|
2012-08-16 22:23:25 -06:00
|
|
|
list_for_each_entry(subdrv, &exynos_drm_subdrv_list, list) {
|
2014-05-08 23:25:20 -06:00
|
|
|
if (subdrv->remove)
|
|
|
|
subdrv->remove(dev, subdrv->dev);
|
2012-08-16 22:23:25 -06:00
|
|
|
}
|
2011-10-04 04:19:01 -06:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
2012-03-16 03:47:09 -06:00
|
|
|
|
|
|
|
int exynos_drm_subdrv_open(struct drm_device *dev, struct drm_file *file)
|
|
|
|
{
|
|
|
|
struct exynos_drm_subdrv *subdrv;
|
|
|
|
int ret;
|
|
|
|
|
|
|
|
list_for_each_entry(subdrv, &exynos_drm_subdrv_list, list) {
|
|
|
|
if (subdrv->open) {
|
2012-04-05 05:49:27 -06:00
|
|
|
ret = subdrv->open(dev, subdrv->dev, file);
|
2012-03-16 03:47:09 -06:00
|
|
|
if (ret)
|
|
|
|
goto err;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
err:
|
2016-03-14 08:22:25 -06:00
|
|
|
list_for_each_entry_continue_reverse(subdrv, &exynos_drm_subdrv_list, list) {
|
2012-03-16 03:47:09 -06:00
|
|
|
if (subdrv->close)
|
2012-04-05 05:49:27 -06:00
|
|
|
subdrv->close(dev, subdrv->dev, file);
|
2012-03-16 03:47:09 -06:00
|
|
|
}
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
void exynos_drm_subdrv_close(struct drm_device *dev, struct drm_file *file)
|
|
|
|
{
|
|
|
|
struct exynos_drm_subdrv *subdrv;
|
|
|
|
|
|
|
|
list_for_each_entry(subdrv, &exynos_drm_subdrv_list, list) {
|
|
|
|
if (subdrv->close)
|
2012-04-05 05:49:27 -06:00
|
|
|
subdrv->close(dev, subdrv->dev, file);
|
2012-03-16 03:47:09 -06:00
|
|
|
}
|
|
|
|
}
|