blob: 4b6c8bf591a4cec80da23adf4be388501a266cec [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) {
30 case DRM_MODE_CONNECTOR_HDMIA:
31 case DRM_MODE_CONNECTOR_HDMIB:
32 return meson_hdmitx_dev_bind(drm, type, intf);
33
34 case DRM_MODE_CONNECTOR_TV:
35 return meson_cvbs_dev_bind(drm, type, intf);
36
yujun.zhangefc31022023-06-21 22:40:44 +080037#ifndef CONFIG_AMLOGIC_ZAPPER_CUT
yujun.zhang54bd40d2022-06-07 01:52:43 +080038 case DRM_MODE_CONNECTOR_LVDS:
39 case DRM_MODE_CONNECTOR_DSI:
40 case DRM_MODE_CONNECTOR_eDP:
41 return meson_panel_dev_bind(drm, type, intf);
yujun.zhangefc31022023-06-21 22:40:44 +080042#endif
yujun.zhang54bd40d2022-06-07 01:52:43 +080043
wenlong.zhang1b8d3752023-04-27 11:36:46 +000044 case DRM_MODE_CONNECTOR_MESON_DUMMY_L:
45 return meson_dummyl_dev_bind(drm, type, intf);
46
congyang.huangae3c70a2023-08-23 09:42:46 +080047 case DRM_MODE_CONNECTOR_MESON_DUMMY_P:
48 return meson_dummyp_dev_bind(drm, type, intf);
49
yujun.zhang54bd40d2022-06-07 01:52:43 +080050 default:
51 pr_err("unknown connector tye %d\n", type);
52 return 0;
53 };
54
55 return 0;
56}
57EXPORT_SYMBOL(meson_connector_dev_bind);
58
59int meson_connector_dev_unbind(struct drm_device *drm,
60 int type, int connector_id)
61{
62 /*amlogic extend lcd*/
63 if (type > DRM_MODE_MESON_CONNECTOR_PANEL_START &&
64 type < DRM_MODE_MESON_CONNECTOR_PANEL_END) {
yujun.zhangefc31022023-06-21 22:40:44 +080065#ifndef CONFIG_AMLOGIC_ZAPPER_CUT
yujun.zhang54bd40d2022-06-07 01:52:43 +080066 return meson_panel_dev_unbind(drm, type, connector_id);
yujun.zhangefc31022023-06-21 22:40:44 +080067#else
68 pr_err("Panel connector is not supported!\n");
69 return -1;
70#endif
yujun.zhang54bd40d2022-06-07 01:52:43 +080071 }
72
73 switch (type) {
74 case DRM_MODE_CONNECTOR_HDMIA:
75 case DRM_MODE_CONNECTOR_HDMIB:
76 return meson_hdmitx_dev_unbind(drm, type, connector_id);
77
78 case DRM_MODE_CONNECTOR_TV:
79 return meson_cvbs_dev_unbind(drm, type, connector_id);
80
yujun.zhangefc31022023-06-21 22:40:44 +080081#ifndef CONFIG_AMLOGIC_ZAPPER_CUT
yujun.zhang54bd40d2022-06-07 01:52:43 +080082 case DRM_MODE_CONNECTOR_LVDS:
83 case DRM_MODE_CONNECTOR_DSI:
84 case DRM_MODE_CONNECTOR_eDP:
85 return meson_panel_dev_unbind(drm, type, connector_id);
yujun.zhangefc31022023-06-21 22:40:44 +080086#endif
yujun.zhang54bd40d2022-06-07 01:52:43 +080087
wenlong.zhang1b8d3752023-04-27 11:36:46 +000088 case DRM_MODE_CONNECTOR_MESON_DUMMY_L:
89 return meson_dummyl_dev_unbind(drm, type, connector_id);
90
congyang.huangae3c70a2023-08-23 09:42:46 +080091 case DRM_MODE_CONNECTOR_MESON_DUMMY_P:
92 return meson_dummyp_dev_unbind(drm, type, connector_id);
93
yujun.zhang54bd40d2022-06-07 01:52:43 +080094 default:
95 pr_err("unknown connector tye %d\n", type);
96 return 0;
97 };
98}
99EXPORT_SYMBOL(meson_connector_dev_unbind);
100