diff options
Diffstat (limited to 'drivers/gpu/drm/exynos/exynos_hdmi.c')
-rw-r--r-- | drivers/gpu/drm/exynos/exynos_hdmi.c | 65 |
1 files changed, 30 insertions, 35 deletions
diff --git a/drivers/gpu/drm/exynos/exynos_hdmi.c b/drivers/gpu/drm/exynos/exynos_hdmi.c index 563a19e62eb2..5765a161abdd 100644 --- a/drivers/gpu/drm/exynos/exynos_hdmi.c +++ b/drivers/gpu/drm/exynos/exynos_hdmi.c | |||
@@ -49,7 +49,6 @@ | |||
49 | #include <linux/gpio.h> | 49 | #include <linux/gpio.h> |
50 | #include <media/s5p_hdmi.h> | 50 | #include <media/s5p_hdmi.h> |
51 | 51 | ||
52 | #define get_hdmi_display(dev) platform_get_drvdata(to_platform_device(dev)) | ||
53 | #define ctx_from_connector(c) container_of(c, struct hdmi_context, connector) | 52 | #define ctx_from_connector(c) container_of(c, struct hdmi_context, connector) |
54 | 53 | ||
55 | #define HOTPLUG_DEBOUNCE_MS 1100 | 54 | #define HOTPLUG_DEBOUNCE_MS 1100 |
@@ -182,6 +181,7 @@ struct hdmi_conf_regs { | |||
182 | }; | 181 | }; |
183 | 182 | ||
184 | struct hdmi_context { | 183 | struct hdmi_context { |
184 | struct exynos_drm_display display; | ||
185 | struct device *dev; | 185 | struct device *dev; |
186 | struct drm_device *drm_dev; | 186 | struct drm_device *drm_dev; |
187 | struct drm_connector connector; | 187 | struct drm_connector connector; |
@@ -213,6 +213,11 @@ struct hdmi_context { | |||
213 | enum hdmi_type type; | 213 | enum hdmi_type type; |
214 | }; | 214 | }; |
215 | 215 | ||
216 | static inline struct hdmi_context *display_to_hdmi(struct exynos_drm_display *d) | ||
217 | { | ||
218 | return container_of(d, struct hdmi_context, display); | ||
219 | } | ||
220 | |||
216 | struct hdmiphy_config { | 221 | struct hdmiphy_config { |
217 | int pixel_clock; | 222 | int pixel_clock; |
218 | u8 conf[32]; | 223 | u8 conf[32]; |
@@ -1123,7 +1128,7 @@ static struct drm_connector_helper_funcs hdmi_connector_helper_funcs = { | |||
1123 | static int hdmi_create_connector(struct exynos_drm_display *display, | 1128 | static int hdmi_create_connector(struct exynos_drm_display *display, |
1124 | struct drm_encoder *encoder) | 1129 | struct drm_encoder *encoder) |
1125 | { | 1130 | { |
1126 | struct hdmi_context *hdata = display->ctx; | 1131 | struct hdmi_context *hdata = display_to_hdmi(display); |
1127 | struct drm_connector *connector = &hdata->connector; | 1132 | struct drm_connector *connector = &hdata->connector; |
1128 | int ret; | 1133 | int ret; |
1129 | 1134 | ||
@@ -2000,7 +2005,7 @@ static void hdmi_v14_mode_set(struct hdmi_context *hdata, | |||
2000 | static void hdmi_mode_set(struct exynos_drm_display *display, | 2005 | static void hdmi_mode_set(struct exynos_drm_display *display, |
2001 | struct drm_display_mode *mode) | 2006 | struct drm_display_mode *mode) |
2002 | { | 2007 | { |
2003 | struct hdmi_context *hdata = display->ctx; | 2008 | struct hdmi_context *hdata = display_to_hdmi(display); |
2004 | struct drm_display_mode *m = mode; | 2009 | struct drm_display_mode *m = mode; |
2005 | 2010 | ||
2006 | DRM_DEBUG_KMS("xres=%d, yres=%d, refresh=%d, intl=%s\n", | 2011 | DRM_DEBUG_KMS("xres=%d, yres=%d, refresh=%d, intl=%s\n", |
@@ -2019,7 +2024,7 @@ static void hdmi_mode_set(struct exynos_drm_display *display, | |||
2019 | 2024 | ||
2020 | static void hdmi_commit(struct exynos_drm_display *display) | 2025 | static void hdmi_commit(struct exynos_drm_display *display) |
2021 | { | 2026 | { |
2022 | struct hdmi_context *hdata = display->ctx; | 2027 | struct hdmi_context *hdata = display_to_hdmi(display); |
2023 | 2028 | ||
2024 | mutex_lock(&hdata->hdmi_mutex); | 2029 | mutex_lock(&hdata->hdmi_mutex); |
2025 | if (!hdata->powered) { | 2030 | if (!hdata->powered) { |
@@ -2033,7 +2038,7 @@ static void hdmi_commit(struct exynos_drm_display *display) | |||
2033 | 2038 | ||
2034 | static void hdmi_poweron(struct exynos_drm_display *display) | 2039 | static void hdmi_poweron(struct exynos_drm_display *display) |
2035 | { | 2040 | { |
2036 | struct hdmi_context *hdata = display->ctx; | 2041 | struct hdmi_context *hdata = display_to_hdmi(display); |
2037 | struct hdmi_resources *res = &hdata->res; | 2042 | struct hdmi_resources *res = &hdata->res; |
2038 | 2043 | ||
2039 | mutex_lock(&hdata->hdmi_mutex); | 2044 | mutex_lock(&hdata->hdmi_mutex); |
@@ -2064,7 +2069,7 @@ static void hdmi_poweron(struct exynos_drm_display *display) | |||
2064 | 2069 | ||
2065 | static void hdmi_poweroff(struct exynos_drm_display *display) | 2070 | static void hdmi_poweroff(struct exynos_drm_display *display) |
2066 | { | 2071 | { |
2067 | struct hdmi_context *hdata = display->ctx; | 2072 | struct hdmi_context *hdata = display_to_hdmi(display); |
2068 | struct hdmi_resources *res = &hdata->res; | 2073 | struct hdmi_resources *res = &hdata->res; |
2069 | 2074 | ||
2070 | mutex_lock(&hdata->hdmi_mutex); | 2075 | mutex_lock(&hdata->hdmi_mutex); |
@@ -2099,7 +2104,7 @@ out: | |||
2099 | 2104 | ||
2100 | static void hdmi_dpms(struct exynos_drm_display *display, int mode) | 2105 | static void hdmi_dpms(struct exynos_drm_display *display, int mode) |
2101 | { | 2106 | { |
2102 | struct hdmi_context *hdata = display->ctx; | 2107 | struct hdmi_context *hdata = display_to_hdmi(display); |
2103 | struct drm_encoder *encoder = hdata->encoder; | 2108 | struct drm_encoder *encoder = hdata->encoder; |
2104 | struct drm_crtc *crtc = encoder->crtc; | 2109 | struct drm_crtc *crtc = encoder->crtc; |
2105 | struct drm_crtc_helper_funcs *funcs = NULL; | 2110 | struct drm_crtc_helper_funcs *funcs = NULL; |
@@ -2143,11 +2148,6 @@ static struct exynos_drm_display_ops hdmi_display_ops = { | |||
2143 | .commit = hdmi_commit, | 2148 | .commit = hdmi_commit, |
2144 | }; | 2149 | }; |
2145 | 2150 | ||
2146 | static struct exynos_drm_display hdmi_display = { | ||
2147 | .type = EXYNOS_DISPLAY_TYPE_HDMI, | ||
2148 | .ops = &hdmi_display_ops, | ||
2149 | }; | ||
2150 | |||
2151 | static void hdmi_hotplug_work_func(struct work_struct *work) | 2151 | static void hdmi_hotplug_work_func(struct work_struct *work) |
2152 | { | 2152 | { |
2153 | struct hdmi_context *hdata; | 2153 | struct hdmi_context *hdata; |
@@ -2302,12 +2302,11 @@ MODULE_DEVICE_TABLE (of, hdmi_match_types); | |||
2302 | static int hdmi_bind(struct device *dev, struct device *master, void *data) | 2302 | static int hdmi_bind(struct device *dev, struct device *master, void *data) |
2303 | { | 2303 | { |
2304 | struct drm_device *drm_dev = data; | 2304 | struct drm_device *drm_dev = data; |
2305 | struct hdmi_context *hdata; | 2305 | struct hdmi_context *hdata = dev_get_drvdata(dev); |
2306 | 2306 | ||
2307 | hdata = hdmi_display.ctx; | ||
2308 | hdata->drm_dev = drm_dev; | 2307 | hdata->drm_dev = drm_dev; |
2309 | 2308 | ||
2310 | return exynos_drm_create_enc_conn(drm_dev, &hdmi_display); | 2309 | return exynos_drm_create_enc_conn(drm_dev, &hdata->display); |
2311 | } | 2310 | } |
2312 | 2311 | ||
2313 | static void hdmi_unbind(struct device *dev, struct device *master, void *data) | 2312 | static void hdmi_unbind(struct device *dev, struct device *master, void *data) |
@@ -2349,31 +2348,28 @@ static int hdmi_probe(struct platform_device *pdev) | |||
2349 | struct resource *res; | 2348 | struct resource *res; |
2350 | int ret; | 2349 | int ret; |
2351 | 2350 | ||
2352 | ret = exynos_drm_component_add(&pdev->dev, EXYNOS_DEVICE_TYPE_CONNECTOR, | 2351 | if (!dev->of_node) |
2353 | hdmi_display.type); | 2352 | return -ENODEV; |
2354 | if (ret) | ||
2355 | return ret; | ||
2356 | |||
2357 | if (!dev->of_node) { | ||
2358 | ret = -ENODEV; | ||
2359 | goto err_del_component; | ||
2360 | } | ||
2361 | 2353 | ||
2362 | pdata = drm_hdmi_dt_parse_pdata(dev); | 2354 | pdata = drm_hdmi_dt_parse_pdata(dev); |
2363 | if (!pdata) { | 2355 | if (!pdata) |
2364 | ret = -EINVAL; | 2356 | return -EINVAL; |
2365 | goto err_del_component; | ||
2366 | } | ||
2367 | 2357 | ||
2368 | hdata = devm_kzalloc(dev, sizeof(struct hdmi_context), GFP_KERNEL); | 2358 | hdata = devm_kzalloc(dev, sizeof(struct hdmi_context), GFP_KERNEL); |
2369 | if (!hdata) { | 2359 | if (!hdata) |
2370 | ret = -ENOMEM; | 2360 | return -ENOMEM; |
2371 | goto err_del_component; | 2361 | |
2372 | } | 2362 | hdata->display.type = EXYNOS_DISPLAY_TYPE_HDMI; |
2363 | hdata->display.ops = &hdmi_display_ops; | ||
2364 | |||
2365 | ret = exynos_drm_component_add(&pdev->dev, EXYNOS_DEVICE_TYPE_CONNECTOR, | ||
2366 | hdata->display.type); | ||
2367 | if (ret) | ||
2368 | return ret; | ||
2373 | 2369 | ||
2374 | mutex_init(&hdata->hdmi_mutex); | 2370 | mutex_init(&hdata->hdmi_mutex); |
2375 | 2371 | ||
2376 | platform_set_drvdata(pdev, &hdmi_display); | 2372 | platform_set_drvdata(pdev, hdata); |
2377 | 2373 | ||
2378 | match = of_match_node(hdmi_match_types, dev->of_node); | 2374 | match = of_match_node(hdmi_match_types, dev->of_node); |
2379 | if (!match) { | 2375 | if (!match) { |
@@ -2485,7 +2481,6 @@ out_get_phy_port: | |||
2485 | } | 2481 | } |
2486 | 2482 | ||
2487 | pm_runtime_enable(dev); | 2483 | pm_runtime_enable(dev); |
2488 | hdmi_display.ctx = hdata; | ||
2489 | 2484 | ||
2490 | ret = component_add(&pdev->dev, &hdmi_component_ops); | 2485 | ret = component_add(&pdev->dev, &hdmi_component_ops); |
2491 | if (ret) | 2486 | if (ret) |
@@ -2510,7 +2505,7 @@ err_del_component: | |||
2510 | 2505 | ||
2511 | static int hdmi_remove(struct platform_device *pdev) | 2506 | static int hdmi_remove(struct platform_device *pdev) |
2512 | { | 2507 | { |
2513 | struct hdmi_context *hdata = hdmi_display.ctx; | 2508 | struct hdmi_context *hdata = platform_get_drvdata(pdev); |
2514 | 2509 | ||
2515 | cancel_delayed_work_sync(&hdata->hotplug_work); | 2510 | cancel_delayed_work_sync(&hdata->hotplug_work); |
2516 | 2511 | ||