![Dave Airlie](/assets/img/avatar_default.png)
Inki writes: "this patch set updates exynos drm framework and includes minor fixups. and this pull request except hdmi device tree support patch set posted by Rahul Sharma because that includes media side patch so for this patch set, we may have git pull one more time in addition, if we get an agreement with media guys. for this patch, you can refer to below link, http://comments.gmane.org/gmane.comp.video.dri.devel/74504 this pull request adds hdmi device tree support and includes related patch set such as disabling of hdmi internal interrupt, suppport for platform variants for hdmi and mixer, support to disable video processor based on platform type and removal of drm common platform data. as you know, this patch set was delayed because it included an media side patch. so for this, we got an ack from v4l2-based hdmi driver author, Tomasz Stanislawski." * 'exynos-drm-next' of git://git.infradead.org/users/kmpark/linux-samsung: (34 commits) drm: exynos: hdmi: remove drm common hdmi platform data struct drm: exynos: hdmi: add support for exynos5 hdmi drm: exynos: hdmi: replace is_v13 with version check in hdmi drm: exynos: hdmi: add support for exynos5 mixer drm: exynos: hdmi: add support to disable video processor in mixer drm: exynos: hdmi: add support for platform variants for mixer drm: exynos: hdmi: add support for exynos5 hdmiphy drm: exynos: hdmi: add support for exynos5 ddc drm: exynos: remove drm hdmi platform data struct drm: exynos: hdmi: turn off HPD interrupt in HDMI chip drm: exynos: hdmi: use s5p-hdmi platform data drm: exynos: hdmi: fix interrupt handling drm: exynos: hdmi: support for platform variants media: s5p-hdmi: add HPD GPIO to platform data drm/exynos: fix kcalloc size of g2d cmdlist node drm/exynos: fix to calculate CRTC shown via screen drm/exynos: fix display power call issue. drm/exynos: add platform_device_id table and driver data for drm fimd drm/exynos: Fix potential NULL pointer dereference drm/exynos: support drm_wait_vblank feature for VIDI ... Conflicts: include/drm/exynos_drm.h
251 lines
6 KiB
C
251 lines
6 KiB
C
/* 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>
|
|
*
|
|
* Permission is hereby granted, free of charge, to any person obtaining a
|
|
* copy of this software and associated documentation files (the "Software"),
|
|
* to deal in the Software without restriction, including without limitation
|
|
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
|
* and/or sell copies of the Software, and to permit persons to whom the
|
|
* Software is furnished to do so, subject to the following conditions:
|
|
*
|
|
* The above copyright notice and this permission notice (including the next
|
|
* paragraph) shall be included in all copies or substantial portions of the
|
|
* Software.
|
|
*
|
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
|
* VA LINUX SYSTEMS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
|
|
* OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
|
|
* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
|
* OTHER DEALINGS IN THE SOFTWARE.
|
|
*/
|
|
|
|
#include <drm/drmP.h>
|
|
#include "exynos_drm_drv.h"
|
|
#include "exynos_drm_encoder.h"
|
|
#include "exynos_drm_connector.h"
|
|
#include "exynos_drm_fbdev.h"
|
|
|
|
static LIST_HEAD(exynos_drm_subdrv_list);
|
|
|
|
static int exynos_drm_create_enc_conn(struct drm_device *dev,
|
|
struct exynos_drm_subdrv *subdrv)
|
|
{
|
|
struct drm_encoder *encoder;
|
|
struct drm_connector *connector;
|
|
int ret;
|
|
|
|
DRM_DEBUG_DRIVER("%s\n", __FILE__);
|
|
|
|
subdrv->manager->dev = subdrv->dev;
|
|
|
|
/* create and initialize a encoder for this sub driver. */
|
|
encoder = exynos_drm_encoder_create(dev, subdrv->manager,
|
|
(1 << MAX_CRTC) - 1);
|
|
if (!encoder) {
|
|
DRM_ERROR("failed to create encoder\n");
|
|
return -EFAULT;
|
|
}
|
|
|
|
/*
|
|
* create and initialize a connector for this sub driver and
|
|
* attach the encoder created above to the connector.
|
|
*/
|
|
connector = exynos_drm_connector_create(dev, encoder);
|
|
if (!connector) {
|
|
DRM_ERROR("failed to create connector\n");
|
|
ret = -EFAULT;
|
|
goto err_destroy_encoder;
|
|
}
|
|
|
|
subdrv->encoder = encoder;
|
|
subdrv->connector = connector;
|
|
|
|
return 0;
|
|
|
|
err_destroy_encoder:
|
|
encoder->funcs->destroy(encoder);
|
|
return ret;
|
|
}
|
|
|
|
static void exynos_drm_destroy_enc_conn(struct exynos_drm_subdrv *subdrv)
|
|
{
|
|
if (subdrv->encoder) {
|
|
struct drm_encoder *encoder = subdrv->encoder;
|
|
encoder->funcs->destroy(encoder);
|
|
subdrv->encoder = NULL;
|
|
}
|
|
|
|
if (subdrv->connector) {
|
|
struct drm_connector *connector = subdrv->connector;
|
|
connector->funcs->destroy(connector);
|
|
subdrv->connector = NULL;
|
|
}
|
|
}
|
|
|
|
static int exynos_drm_subdrv_probe(struct drm_device *dev,
|
|
struct exynos_drm_subdrv *subdrv)
|
|
{
|
|
if (subdrv->probe) {
|
|
int ret;
|
|
|
|
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 or by load()
|
|
* of exynos drm driver.
|
|
*
|
|
* P.S. note that this driver is considered for modularization.
|
|
*/
|
|
ret = subdrv->probe(dev, subdrv->dev);
|
|
if (ret)
|
|
return ret;
|
|
}
|
|
|
|
return 0;
|
|
}
|
|
|
|
static void exynos_drm_subdrv_remove(struct drm_device *dev,
|
|
struct exynos_drm_subdrv *subdrv)
|
|
{
|
|
DRM_DEBUG_DRIVER("%s\n", __FILE__);
|
|
|
|
if (subdrv->remove)
|
|
subdrv->remove(dev, subdrv->dev);
|
|
}
|
|
|
|
int exynos_drm_device_register(struct drm_device *dev)
|
|
{
|
|
struct exynos_drm_subdrv *subdrv, *n;
|
|
unsigned int fine_cnt = 0;
|
|
int err;
|
|
|
|
DRM_DEBUG_DRIVER("%s\n", __FILE__);
|
|
|
|
if (!dev)
|
|
return -EINVAL;
|
|
|
|
list_for_each_entry_safe(subdrv, n, &exynos_drm_subdrv_list, list) {
|
|
err = exynos_drm_subdrv_probe(dev, subdrv);
|
|
if (err) {
|
|
DRM_DEBUG("exynos drm subdrv probe failed.\n");
|
|
list_del(&subdrv->list);
|
|
continue;
|
|
}
|
|
|
|
/*
|
|
* if manager is null then it means that this sub driver
|
|
* doesn't need encoder and connector.
|
|
*/
|
|
if (!subdrv->manager) {
|
|
fine_cnt++;
|
|
continue;
|
|
}
|
|
|
|
err = exynos_drm_create_enc_conn(dev, subdrv);
|
|
if (err) {
|
|
DRM_DEBUG("failed to create encoder and connector.\n");
|
|
exynos_drm_subdrv_remove(dev, subdrv);
|
|
list_del(&subdrv->list);
|
|
continue;
|
|
}
|
|
|
|
fine_cnt++;
|
|
}
|
|
|
|
if (!fine_cnt)
|
|
return -EINVAL;
|
|
|
|
return 0;
|
|
}
|
|
EXPORT_SYMBOL_GPL(exynos_drm_device_register);
|
|
|
|
int exynos_drm_device_unregister(struct drm_device *dev)
|
|
{
|
|
struct exynos_drm_subdrv *subdrv;
|
|
|
|
DRM_DEBUG_DRIVER("%s\n", __FILE__);
|
|
|
|
if (!dev) {
|
|
WARN(1, "Unexpected drm device unregister!\n");
|
|
return -EINVAL;
|
|
}
|
|
|
|
list_for_each_entry(subdrv, &exynos_drm_subdrv_list, list) {
|
|
exynos_drm_subdrv_remove(dev, subdrv);
|
|
exynos_drm_destroy_enc_conn(subdrv);
|
|
}
|
|
|
|
return 0;
|
|
}
|
|
EXPORT_SYMBOL_GPL(exynos_drm_device_unregister);
|
|
|
|
int exynos_drm_subdrv_register(struct exynos_drm_subdrv *subdrv)
|
|
{
|
|
DRM_DEBUG_DRIVER("%s\n", __FILE__);
|
|
|
|
if (!subdrv)
|
|
return -EINVAL;
|
|
|
|
list_add_tail(&subdrv->list, &exynos_drm_subdrv_list);
|
|
|
|
return 0;
|
|
}
|
|
EXPORT_SYMBOL_GPL(exynos_drm_subdrv_register);
|
|
|
|
int exynos_drm_subdrv_unregister(struct exynos_drm_subdrv *subdrv)
|
|
{
|
|
DRM_DEBUG_DRIVER("%s\n", __FILE__);
|
|
|
|
if (!subdrv)
|
|
return -EINVAL;
|
|
|
|
list_del(&subdrv->list);
|
|
|
|
return 0;
|
|
}
|
|
EXPORT_SYMBOL_GPL(exynos_drm_subdrv_unregister);
|
|
|
|
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) {
|
|
ret = subdrv->open(dev, subdrv->dev, file);
|
|
if (ret)
|
|
goto err;
|
|
}
|
|
}
|
|
|
|
return 0;
|
|
|
|
err:
|
|
list_for_each_entry_reverse(subdrv, &subdrv->list, list) {
|
|
if (subdrv->close)
|
|
subdrv->close(dev, subdrv->dev, file);
|
|
}
|
|
return ret;
|
|
}
|
|
EXPORT_SYMBOL_GPL(exynos_drm_subdrv_open);
|
|
|
|
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)
|
|
subdrv->close(dev, subdrv->dev, file);
|
|
}
|
|
}
|
|
EXPORT_SYMBOL_GPL(exynos_drm_subdrv_close);
|