| .. | .. |
|---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-or-later |
|---|
| 1 | 2 | /* |
|---|
| 2 | 3 | * Copyright 2015 Freescale Semiconductor, Inc. |
|---|
| 3 | 4 | * |
|---|
| 4 | 5 | * Freescale DCU drm device driver |
|---|
| 5 | | - * |
|---|
| 6 | | - * This program is free software; you can redistribute it and/or modify |
|---|
| 7 | | - * it under the terms of the GNU General Public License as published by |
|---|
| 8 | | - * the Free Software Foundation; either version 2 of the License, or |
|---|
| 9 | | - * (at your option) any later version. |
|---|
| 10 | 6 | */ |
|---|
| 11 | 7 | |
|---|
| 12 | 8 | #include <linux/backlight.h> |
|---|
| 13 | 9 | #include <linux/of_graph.h> |
|---|
| 14 | 10 | |
|---|
| 15 | | -#include <drm/drmP.h> |
|---|
| 16 | 11 | #include <drm/drm_atomic_helper.h> |
|---|
| 17 | | -#include <drm/drm_crtc_helper.h> |
|---|
| 12 | +#include <drm/drm_bridge.h> |
|---|
| 18 | 13 | #include <drm/drm_of.h> |
|---|
| 19 | 14 | #include <drm/drm_panel.h> |
|---|
| 15 | +#include <drm/drm_probe_helper.h> |
|---|
| 16 | +#include <drm/drm_simple_kms_helper.h> |
|---|
| 20 | 17 | |
|---|
| 21 | 18 | #include "fsl_dcu_drm_drv.h" |
|---|
| 22 | 19 | #include "fsl_tcon.h" |
|---|
| 23 | | - |
|---|
| 24 | | -static void fsl_dcu_drm_encoder_destroy(struct drm_encoder *encoder) |
|---|
| 25 | | -{ |
|---|
| 26 | | - drm_encoder_cleanup(encoder); |
|---|
| 27 | | -} |
|---|
| 28 | | - |
|---|
| 29 | | -static const struct drm_encoder_funcs encoder_funcs = { |
|---|
| 30 | | - .destroy = fsl_dcu_drm_encoder_destroy, |
|---|
| 31 | | -}; |
|---|
| 32 | 20 | |
|---|
| 33 | 21 | int fsl_dcu_drm_encoder_create(struct fsl_dcu_drm_device *fsl_dev, |
|---|
| 34 | 22 | struct drm_crtc *crtc) |
|---|
| .. | .. |
|---|
| 42 | 30 | if (fsl_dev->tcon) |
|---|
| 43 | 31 | fsl_tcon_bypass_enable(fsl_dev->tcon); |
|---|
| 44 | 32 | |
|---|
| 45 | | - ret = drm_encoder_init(fsl_dev->drm, encoder, &encoder_funcs, |
|---|
| 46 | | - DRM_MODE_ENCODER_LVDS, NULL); |
|---|
| 33 | + ret = drm_simple_encoder_init(fsl_dev->drm, encoder, |
|---|
| 34 | + DRM_MODE_ENCODER_LVDS); |
|---|
| 47 | 35 | if (ret < 0) |
|---|
| 48 | 36 | return ret; |
|---|
| 49 | 37 | |
|---|
| .. | .. |
|---|
| 52 | 40 | |
|---|
| 53 | 41 | static void fsl_dcu_drm_connector_destroy(struct drm_connector *connector) |
|---|
| 54 | 42 | { |
|---|
| 55 | | - struct fsl_dcu_drm_connector *fsl_con = to_fsl_dcu_connector(connector); |
|---|
| 56 | | - |
|---|
| 57 | 43 | drm_connector_unregister(connector); |
|---|
| 58 | | - drm_panel_detach(fsl_con->panel); |
|---|
| 59 | 44 | drm_connector_cleanup(connector); |
|---|
| 60 | 45 | } |
|---|
| 61 | 46 | |
|---|
| .. | .. |
|---|
| 70 | 55 | static int fsl_dcu_drm_connector_get_modes(struct drm_connector *connector) |
|---|
| 71 | 56 | { |
|---|
| 72 | 57 | struct fsl_dcu_drm_connector *fsl_connector; |
|---|
| 73 | | - int (*get_modes)(struct drm_panel *panel); |
|---|
| 74 | | - int num_modes = 0; |
|---|
| 75 | 58 | |
|---|
| 76 | 59 | fsl_connector = to_fsl_dcu_connector(connector); |
|---|
| 77 | | - if (fsl_connector->panel && fsl_connector->panel->funcs && |
|---|
| 78 | | - fsl_connector->panel->funcs->get_modes) { |
|---|
| 79 | | - get_modes = fsl_connector->panel->funcs->get_modes; |
|---|
| 80 | | - num_modes = get_modes(fsl_connector->panel); |
|---|
| 81 | | - } |
|---|
| 82 | | - |
|---|
| 83 | | - return num_modes; |
|---|
| 60 | + return drm_panel_get_modes(fsl_connector->panel, connector); |
|---|
| 84 | 61 | } |
|---|
| 85 | 62 | |
|---|
| 86 | 63 | static int fsl_dcu_drm_connector_mode_valid(struct drm_connector *connector, |
|---|
| .. | .. |
|---|
| 121 | 98 | if (ret < 0) |
|---|
| 122 | 99 | goto err_sysfs; |
|---|
| 123 | 100 | |
|---|
| 124 | | - ret = drm_panel_attach(panel, connector); |
|---|
| 125 | | - if (ret) { |
|---|
| 126 | | - dev_err(fsl_dev->dev, "failed to attach panel\n"); |
|---|
| 127 | | - goto err_sysfs; |
|---|
| 128 | | - } |
|---|
| 129 | | - |
|---|
| 130 | 101 | return 0; |
|---|
| 131 | 102 | |
|---|
| 132 | 103 | err_sysfs: |
|---|
| .. | .. |
|---|
| 163 | 134 | return fsl_dcu_attach_panel(fsl_dev, panel); |
|---|
| 164 | 135 | } |
|---|
| 165 | 136 | |
|---|
| 166 | | - return drm_bridge_attach(&fsl_dev->encoder, bridge, NULL); |
|---|
| 137 | + return drm_bridge_attach(&fsl_dev->encoder, bridge, NULL, 0); |
|---|
| 167 | 138 | } |
|---|