blob: 458acc77574c4f3b03469a8ad5caaceaf94c8be3 [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"
yujun.zhang54bd40d2022-06-07 01:52:43 +080013
14int meson_connector_dev_bind(struct drm_device *drm,
15 int type, struct meson_connector_dev *intf)
16{
17 /*amlogic extend lcd*/
18 if (type > DRM_MODE_MESON_CONNECTOR_PANEL_START &&
19 type < DRM_MODE_MESON_CONNECTOR_PANEL_END) {
yujun.zhangefc31022023-06-21 22:40:44 +080020#ifndef CONFIG_AMLOGIC_ZAPPER_CUT
yujun.zhang54bd40d2022-06-07 01:52:43 +080021 return meson_panel_dev_bind(drm, type, intf);
yujun.zhangefc31022023-06-21 22:40:44 +080022#else
23 pr_err("Panel connector is not supported!\n");
24 return -1;
25#endif
yujun.zhang54bd40d2022-06-07 01:52:43 +080026 }
27
28 switch (type) {
29 case DRM_MODE_CONNECTOR_HDMIA:
30 case DRM_MODE_CONNECTOR_HDMIB:
31 return meson_hdmitx_dev_bind(drm, type, intf);
32
33 case DRM_MODE_CONNECTOR_TV:
34 return meson_cvbs_dev_bind(drm, type, intf);
35
yujun.zhangefc31022023-06-21 22:40:44 +080036#ifndef CONFIG_AMLOGIC_ZAPPER_CUT
yujun.zhang54bd40d2022-06-07 01:52:43 +080037 case DRM_MODE_CONNECTOR_LVDS:
38 case DRM_MODE_CONNECTOR_DSI:
39 case DRM_MODE_CONNECTOR_eDP:
40 return meson_panel_dev_bind(drm, type, intf);
yujun.zhangefc31022023-06-21 22:40:44 +080041#endif
yujun.zhang54bd40d2022-06-07 01:52:43 +080042
wenlong.zhang1b8d3752023-04-27 11:36:46 +000043 case DRM_MODE_CONNECTOR_MESON_DUMMY_L:
44 return meson_dummyl_dev_bind(drm, type, intf);
45
yujun.zhang54bd40d2022-06-07 01:52:43 +080046 default:
47 pr_err("unknown connector tye %d\n", type);
48 return 0;
49 };
50
51 return 0;
52}
53EXPORT_SYMBOL(meson_connector_dev_bind);
54
55int meson_connector_dev_unbind(struct drm_device *drm,
56 int type, int connector_id)
57{
58 /*amlogic extend lcd*/
59 if (type > DRM_MODE_MESON_CONNECTOR_PANEL_START &&
60 type < DRM_MODE_MESON_CONNECTOR_PANEL_END) {
yujun.zhangefc31022023-06-21 22:40:44 +080061#ifndef CONFIG_AMLOGIC_ZAPPER_CUT
yujun.zhang54bd40d2022-06-07 01:52:43 +080062 return meson_panel_dev_unbind(drm, type, connector_id);
yujun.zhangefc31022023-06-21 22:40:44 +080063#else
64 pr_err("Panel connector is not supported!\n");
65 return -1;
66#endif
yujun.zhang54bd40d2022-06-07 01:52:43 +080067 }
68
69 switch (type) {
70 case DRM_MODE_CONNECTOR_HDMIA:
71 case DRM_MODE_CONNECTOR_HDMIB:
72 return meson_hdmitx_dev_unbind(drm, type, connector_id);
73
74 case DRM_MODE_CONNECTOR_TV:
75 return meson_cvbs_dev_unbind(drm, type, connector_id);
76
yujun.zhangefc31022023-06-21 22:40:44 +080077#ifndef CONFIG_AMLOGIC_ZAPPER_CUT
yujun.zhang54bd40d2022-06-07 01:52:43 +080078 case DRM_MODE_CONNECTOR_LVDS:
79 case DRM_MODE_CONNECTOR_DSI:
80 case DRM_MODE_CONNECTOR_eDP:
81 return meson_panel_dev_unbind(drm, type, connector_id);
yujun.zhangefc31022023-06-21 22:40:44 +080082#endif
yujun.zhang54bd40d2022-06-07 01:52:43 +080083
wenlong.zhang1b8d3752023-04-27 11:36:46 +000084 case DRM_MODE_CONNECTOR_MESON_DUMMY_L:
85 return meson_dummyl_dev_unbind(drm, type, connector_id);
86
yujun.zhang54bd40d2022-06-07 01:52:43 +080087 default:
88 pr_err("unknown connector tye %d\n", type);
89 return 0;
90 };
91}
92EXPORT_SYMBOL(meson_connector_dev_unbind);
93