blob: 62b3f4c23480e981d8c4baad34b07093f2d3344a [file] [log] [blame]
yujun.zhang54bd40d2022-06-07 01:52:43 +08001// SPDX-License-Identifier: (GPL-2.0+ OR MIT)
2/*
3 * Copyright (c) 2021 Amlogic, Inc. All rights reserved.
4 */
5
6#include <drm/amlogic/meson_drm_bind.h>
7#include "meson_hdmi.h"
8#include "meson_cvbs.h"
yujun.zhangefc31022023-06-21 22:40:44 +08009#ifndef CONFIG_AMLOGIC_ZAPPER_CUT
yujun.zhang54bd40d2022-06-07 01:52:43 +080010#include "meson_lcd.h"
yujun.zhangefc31022023-06-21 22:40:44 +080011#endif
wenlong.zhang1b8d3752023-04-27 11:36:46 +000012#include "meson_dummyl.h"
congyang.huangae3c70a2023-08-23 09:42:46 +080013#include "meson_dummyp.h"
yujun.zhang54bd40d2022-06-07 01:52:43 +080014
15int meson_connector_dev_bind(struct drm_device *drm,
16 int type, struct meson_connector_dev *intf)
17{
18 /*amlogic extend lcd*/
19 if (type > DRM_MODE_MESON_CONNECTOR_PANEL_START &&
20 type < DRM_MODE_MESON_CONNECTOR_PANEL_END) {
yujun.zhangefc31022023-06-21 22:40:44 +080021#ifndef CONFIG_AMLOGIC_ZAPPER_CUT
yujun.zhang54bd40d2022-06-07 01:52:43 +080022 return meson_panel_dev_bind(drm, type, intf);
yujun.zhangefc31022023-06-21 22:40:44 +080023#else
24 pr_err("Panel connector is not supported!\n");
25 return -1;
26#endif
yujun.zhang54bd40d2022-06-07 01:52:43 +080027 }
28
congyang.huang82af31e2024-04-28 15:52:24 +080029 if (type > DRM_MODE_MESON_CONNECTOR_HDMI_START &&
30 type < DRM_MODE_MESON_CONNECTOR_HDMI_END) {
31#ifndef CONFIG_AMLOGIC_DRM_CUT_HDMI
32 return meson_hdmitx_dev_bind(drm, type, intf);
33#else
34 pr_err("hdmi connector is not supported!\n");
35 return -1;
36#endif
37 }
38
yujun.zhang54bd40d2022-06-07 01:52:43 +080039 switch (type) {
robin.zhud5029012024-02-07 19:36:45 +000040#ifndef CONFIG_AMLOGIC_DRM_CUT_HDMI
yujun.zhang54bd40d2022-06-07 01:52:43 +080041 case DRM_MODE_CONNECTOR_HDMIA:
42 case DRM_MODE_CONNECTOR_HDMIB:
43 return meson_hdmitx_dev_bind(drm, type, intf);
robin.zhud5029012024-02-07 19:36:45 +000044#endif
yujun.zhang54bd40d2022-06-07 01:52:43 +080045
robin.zhud5029012024-02-07 19:36:45 +000046#ifndef CONFIG_AMLOGIC_DRM_CUT_CVBS
yujun.zhang54bd40d2022-06-07 01:52:43 +080047 case DRM_MODE_CONNECTOR_TV:
48 return meson_cvbs_dev_bind(drm, type, intf);
robin.zhud5029012024-02-07 19:36:45 +000049#endif
yujun.zhang54bd40d2022-06-07 01:52:43 +080050
yujun.zhangefc31022023-06-21 22:40:44 +080051#ifndef CONFIG_AMLOGIC_ZAPPER_CUT
yujun.zhang54bd40d2022-06-07 01:52:43 +080052 case DRM_MODE_CONNECTOR_LVDS:
53 case DRM_MODE_CONNECTOR_DSI:
54 case DRM_MODE_CONNECTOR_eDP:
55 return meson_panel_dev_bind(drm, type, intf);
yujun.zhangefc31022023-06-21 22:40:44 +080056#endif
yujun.zhang54bd40d2022-06-07 01:52:43 +080057
Dongjin Kim56ea0b42024-10-10 16:09:20 +090058#ifndef CONFIG_ARCH_MESON_ODROID_COMMON
wenlong.zhang1b8d3752023-04-27 11:36:46 +000059 case DRM_MODE_CONNECTOR_MESON_DUMMY_L:
60 return meson_dummyl_dev_bind(drm, type, intf);
61
congyang.huangae3c70a2023-08-23 09:42:46 +080062 case DRM_MODE_CONNECTOR_MESON_DUMMY_P:
63 return meson_dummyp_dev_bind(drm, type, intf);
Dongjin Kim56ea0b42024-10-10 16:09:20 +090064#endif
congyang.huangae3c70a2023-08-23 09:42:46 +080065
yujun.zhang54bd40d2022-06-07 01:52:43 +080066 default:
67 pr_err("unknown connector tye %d\n", type);
68 return 0;
69 };
70
71 return 0;
72}
73EXPORT_SYMBOL(meson_connector_dev_bind);
74
75int meson_connector_dev_unbind(struct drm_device *drm,
76 int type, int connector_id)
77{
78 /*amlogic extend lcd*/
79 if (type > DRM_MODE_MESON_CONNECTOR_PANEL_START &&
80 type < DRM_MODE_MESON_CONNECTOR_PANEL_END) {
yujun.zhangefc31022023-06-21 22:40:44 +080081#ifndef CONFIG_AMLOGIC_ZAPPER_CUT
yujun.zhang54bd40d2022-06-07 01:52:43 +080082 return meson_panel_dev_unbind(drm, type, connector_id);
yujun.zhangefc31022023-06-21 22:40:44 +080083#else
84 pr_err("Panel connector is not supported!\n");
85 return -1;
86#endif
yujun.zhang54bd40d2022-06-07 01:52:43 +080087 }
88
89 switch (type) {
robin.zhud5029012024-02-07 19:36:45 +000090#ifndef CONFIG_AMLOGIC_DRM_CUT_HDMI
yujun.zhang54bd40d2022-06-07 01:52:43 +080091 case DRM_MODE_CONNECTOR_HDMIA:
92 case DRM_MODE_CONNECTOR_HDMIB:
93 return meson_hdmitx_dev_unbind(drm, type, connector_id);
robin.zhud5029012024-02-07 19:36:45 +000094#endif
yujun.zhang54bd40d2022-06-07 01:52:43 +080095
robin.zhud5029012024-02-07 19:36:45 +000096#ifndef CONFIG_AMLOGIC_DRM_CUT_CVBS
yujun.zhang54bd40d2022-06-07 01:52:43 +080097 case DRM_MODE_CONNECTOR_TV:
98 return meson_cvbs_dev_unbind(drm, type, connector_id);
robin.zhud5029012024-02-07 19:36:45 +000099#endif
yujun.zhang54bd40d2022-06-07 01:52:43 +0800100
yujun.zhangefc31022023-06-21 22:40:44 +0800101#ifndef CONFIG_AMLOGIC_ZAPPER_CUT
yujun.zhang54bd40d2022-06-07 01:52:43 +0800102 case DRM_MODE_CONNECTOR_LVDS:
103 case DRM_MODE_CONNECTOR_DSI:
104 case DRM_MODE_CONNECTOR_eDP:
105 return meson_panel_dev_unbind(drm, type, connector_id);
yujun.zhangefc31022023-06-21 22:40:44 +0800106#endif
yujun.zhang54bd40d2022-06-07 01:52:43 +0800107
Dongjin Kim56ea0b42024-10-10 16:09:20 +0900108#ifndef CONFIG_ARCH_MESON_ODROID_COMMON
wenlong.zhang1b8d3752023-04-27 11:36:46 +0000109 case DRM_MODE_CONNECTOR_MESON_DUMMY_L:
110 return meson_dummyl_dev_unbind(drm, type, connector_id);
111
congyang.huangae3c70a2023-08-23 09:42:46 +0800112 case DRM_MODE_CONNECTOR_MESON_DUMMY_P:
113 return meson_dummyp_dev_unbind(drm, type, connector_id);
Dongjin Kim56ea0b42024-10-10 16:09:20 +0900114#endif
congyang.huangae3c70a2023-08-23 09:42:46 +0800115
yujun.zhang54bd40d2022-06-07 01:52:43 +0800116 default:
117 pr_err("unknown connector tye %d\n", type);
118 return 0;
119 };
120}
121EXPORT_SYMBOL(meson_connector_dev_unbind);
122