blob: 8d1b091d17b9496ef52bda4df87c17c60d351aeb [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
29 switch (type) {
robin.zhud5029012024-02-07 19:36:45 +000030#ifndef CONFIG_AMLOGIC_DRM_CUT_HDMI
yujun.zhang54bd40d2022-06-07 01:52:43 +080031 case DRM_MODE_CONNECTOR_HDMIA:
32 case DRM_MODE_CONNECTOR_HDMIB:
33 return meson_hdmitx_dev_bind(drm, type, intf);
robin.zhud5029012024-02-07 19:36:45 +000034#endif
yujun.zhang54bd40d2022-06-07 01:52:43 +080035
robin.zhud5029012024-02-07 19:36:45 +000036#ifndef CONFIG_AMLOGIC_DRM_CUT_CVBS
yujun.zhang54bd40d2022-06-07 01:52:43 +080037 case DRM_MODE_CONNECTOR_TV:
38 return meson_cvbs_dev_bind(drm, type, intf);
robin.zhud5029012024-02-07 19:36:45 +000039#endif
yujun.zhang54bd40d2022-06-07 01:52:43 +080040
yujun.zhangefc31022023-06-21 22:40:44 +080041#ifndef CONFIG_AMLOGIC_ZAPPER_CUT
yujun.zhang54bd40d2022-06-07 01:52:43 +080042 case DRM_MODE_CONNECTOR_LVDS:
43 case DRM_MODE_CONNECTOR_DSI:
44 case DRM_MODE_CONNECTOR_eDP:
45 return meson_panel_dev_bind(drm, type, intf);
yujun.zhangefc31022023-06-21 22:40:44 +080046#endif
yujun.zhang54bd40d2022-06-07 01:52:43 +080047
wenlong.zhang1b8d3752023-04-27 11:36:46 +000048 case DRM_MODE_CONNECTOR_MESON_DUMMY_L:
49 return meson_dummyl_dev_bind(drm, type, intf);
50
congyang.huangae3c70a2023-08-23 09:42:46 +080051 case DRM_MODE_CONNECTOR_MESON_DUMMY_P:
52 return meson_dummyp_dev_bind(drm, type, intf);
53
yujun.zhang54bd40d2022-06-07 01:52:43 +080054 default:
55 pr_err("unknown connector tye %d\n", type);
56 return 0;
57 };
58
59 return 0;
60}
61EXPORT_SYMBOL(meson_connector_dev_bind);
62
63int meson_connector_dev_unbind(struct drm_device *drm,
64 int type, int connector_id)
65{
66 /*amlogic extend lcd*/
67 if (type > DRM_MODE_MESON_CONNECTOR_PANEL_START &&
68 type < DRM_MODE_MESON_CONNECTOR_PANEL_END) {
yujun.zhangefc31022023-06-21 22:40:44 +080069#ifndef CONFIG_AMLOGIC_ZAPPER_CUT
yujun.zhang54bd40d2022-06-07 01:52:43 +080070 return meson_panel_dev_unbind(drm, type, connector_id);
yujun.zhangefc31022023-06-21 22:40:44 +080071#else
72 pr_err("Panel connector is not supported!\n");
73 return -1;
74#endif
yujun.zhang54bd40d2022-06-07 01:52:43 +080075 }
76
77 switch (type) {
robin.zhud5029012024-02-07 19:36:45 +000078#ifndef CONFIG_AMLOGIC_DRM_CUT_HDMI
yujun.zhang54bd40d2022-06-07 01:52:43 +080079 case DRM_MODE_CONNECTOR_HDMIA:
80 case DRM_MODE_CONNECTOR_HDMIB:
81 return meson_hdmitx_dev_unbind(drm, type, connector_id);
robin.zhud5029012024-02-07 19:36:45 +000082#endif
yujun.zhang54bd40d2022-06-07 01:52:43 +080083
robin.zhud5029012024-02-07 19:36:45 +000084#ifndef CONFIG_AMLOGIC_DRM_CUT_CVBS
yujun.zhang54bd40d2022-06-07 01:52:43 +080085 case DRM_MODE_CONNECTOR_TV:
86 return meson_cvbs_dev_unbind(drm, type, connector_id);
robin.zhud5029012024-02-07 19:36:45 +000087#endif
yujun.zhang54bd40d2022-06-07 01:52:43 +080088
yujun.zhangefc31022023-06-21 22:40:44 +080089#ifndef CONFIG_AMLOGIC_ZAPPER_CUT
yujun.zhang54bd40d2022-06-07 01:52:43 +080090 case DRM_MODE_CONNECTOR_LVDS:
91 case DRM_MODE_CONNECTOR_DSI:
92 case DRM_MODE_CONNECTOR_eDP:
93 return meson_panel_dev_unbind(drm, type, connector_id);
yujun.zhangefc31022023-06-21 22:40:44 +080094#endif
yujun.zhang54bd40d2022-06-07 01:52:43 +080095
wenlong.zhang1b8d3752023-04-27 11:36:46 +000096 case DRM_MODE_CONNECTOR_MESON_DUMMY_L:
97 return meson_dummyl_dev_unbind(drm, type, connector_id);
98
congyang.huangae3c70a2023-08-23 09:42:46 +080099 case DRM_MODE_CONNECTOR_MESON_DUMMY_P:
100 return meson_dummyp_dev_unbind(drm, type, connector_id);
101
yujun.zhang54bd40d2022-06-07 01:52:43 +0800102 default:
103 pr_err("unknown connector tye %d\n", type);
104 return 0;
105 };
106}
107EXPORT_SYMBOL(meson_connector_dev_unbind);
108