xref: /openbsd/sys/dev/pci/drm/apple/dcp.h (revision 5dd0baa8)
1 // SPDX-License-Identifier: GPL-2.0-only OR MIT
2 /* Copyright 2021 Alyssa Rosenzweig <alyssa@rosenzweig.io> */
3 
4 #ifndef __APPLE_DCP_H__
5 #define __APPLE_DCP_H__
6 
7 #include <drm/drm_atomic.h>
8 #include <drm/drm_encoder.h>
9 #include <drm/drm_fourcc.h>
10 
11 #include "dcp-internal.h"
12 #include "parser.h"
13 
14 struct apple_crtc {
15 	struct drm_crtc base;
16 	struct drm_pending_vblank_event *event;
17 	bool vsync_disabled;
18 
19 	/* Reference to the DCP device owning this CRTC */
20 	struct platform_device *dcp;
21 };
22 
23 #define to_apple_crtc(x) container_of(x, struct apple_crtc, base)
24 
25 void dcp_hotplug(struct work_struct *work);
26 
27 struct apple_connector {
28 	struct drm_connector base;
29 	bool connected;
30 
31 	struct platform_device *dcp;
32 
33 	/* Workqueue for sending hotplug events to the associated device */
34 	struct work_struct hotplug_wq;
35 };
36 
37 #define to_apple_connector(x) container_of(x, struct apple_connector, base)
38 
39 struct apple_encoder {
40 	struct drm_encoder base;
41 };
42 
43 #define to_apple_encoder(x) container_of(x, struct apple_encoder, base)
44 
45 void dcp_poweroff(struct platform_device *pdev);
46 void dcp_poweron(struct platform_device *pdev);
47 int dcp_crtc_atomic_check(struct drm_crtc *crtc, struct drm_atomic_state *state);
48 int dcp_get_connector_type(struct platform_device *pdev);
49 void dcp_link(struct platform_device *pdev, struct apple_crtc *apple,
50 	      struct apple_connector *connector);
51 int dcp_start(struct platform_device *pdev);
52 int dcp_wait_ready(struct platform_device *pdev, u64 timeout);
53 void dcp_flush(struct drm_crtc *crtc, struct drm_atomic_state *state);
54 bool dcp_is_initialized(struct platform_device *pdev);
55 void apple_crtc_vblank(struct apple_crtc *apple);
56 void dcp_drm_crtc_vblank(struct apple_crtc *crtc);
57 int dcp_get_modes(struct drm_connector *connector);
58 int dcp_mode_valid(struct drm_connector *connector,
59 		   struct drm_display_mode *mode);
60 int dcp_crtc_atomic_modeset(struct drm_crtc *crtc,
61 			    struct drm_atomic_state *state);
62 bool dcp_crtc_mode_fixup(struct drm_crtc *crtc,
63 			 const struct drm_display_mode *mode,
64 			 struct drm_display_mode *adjusted_mode);
65 void dcp_set_dimensions(struct apple_dcp *dcp);
66 void dcp_send_message(struct apple_dcp *dcp, u8 endpoint, u64 message);
67 
68 int iomfb_start_rtkit(struct apple_dcp *dcp);
69 void iomfb_shutdown(struct apple_dcp *dcp);
70 /* rtkit message handler for IOMFB messages */
71 void iomfb_recv_msg(struct apple_dcp *dcp, u64 message);
72 
73 int systemep_init(struct apple_dcp *dcp);
74 int dptxep_init(struct apple_dcp *dcp);
75 int ibootep_init(struct apple_dcp *dcp);
76 #endif
77