xref: /linux/drivers/gpu/drm/gma500/gma_display.h (revision 5027ec19f1049a07df5b0a37b1f462514cf2724b)
1 /* SPDX-License-Identifier: GPL-2.0-only */
2 /*
3  * Copyright © 2006-2011 Intel Corporation
4  *
5  * Authors:
6  *	Eric Anholt <eric@anholt.net>
7  *	Patrik Jakobsson <patrik.r.jakobsson@gmail.com>
8  */
9 
10 #ifndef _GMA_DISPLAY_H_
11 #define _GMA_DISPLAY_H_
12 
13 #include <linux/pm_runtime.h>
14 #include <drm/drm_vblank.h>
15 
16 struct drm_encoder;
17 struct drm_mode_set;
18 
19 struct gma_clock_t {
20 	/* given values */
21 	int n;
22 	int m1, m2;
23 	int p1, p2;
24 	/* derived values */
25 	int dot;
26 	int vco;
27 	int m;
28 	int p;
29 };
30 
31 struct gma_range_t {
32 	int min, max;
33 };
34 
35 struct gma_p2_t {
36 	int dot_limit;
37 	int p2_slow, p2_fast;
38 };
39 
40 struct gma_limit_t {
41 	struct gma_range_t dot, vco, n, m, m1, m2, p, p1;
42 	struct gma_p2_t p2;
43 	bool (*find_pll)(const struct gma_limit_t *, struct drm_crtc *,
44 			 int target, int refclk,
45 			 struct gma_clock_t *best_clock);
46 };
47 
48 struct gma_clock_funcs {
49 	void (*clock)(int refclk, struct gma_clock_t *clock);
50 	const struct gma_limit_t *(*limit)(struct drm_crtc *crtc, int refclk);
51 	bool (*pll_is_valid)(struct drm_crtc *crtc,
52 			     const struct gma_limit_t *limit,
53 			     struct gma_clock_t *clock);
54 };
55 
56 /* Common pipe related functions */
57 extern bool gma_pipe_has_type(struct drm_crtc *crtc, int type);
58 extern void gma_wait_for_vblank(struct drm_device *dev);
59 extern int gma_pipe_set_base(struct drm_crtc *crtc, int x, int y,
60 			     struct drm_framebuffer *old_fb);
61 extern void gma_crtc_load_lut(struct drm_crtc *crtc);
62 extern void gma_crtc_dpms(struct drm_crtc *crtc, int mode);
63 extern void gma_crtc_prepare(struct drm_crtc *crtc);
64 extern void gma_crtc_commit(struct drm_crtc *crtc);
65 extern void gma_crtc_disable(struct drm_crtc *crtc);
66 extern void gma_crtc_destroy(struct drm_crtc *crtc);
67 extern int gma_crtc_page_flip(struct drm_crtc *crtc,
68 			      struct drm_framebuffer *fb,
69 			      struct drm_pending_vblank_event *event,
70 			      uint32_t page_flip_flags,
71 			      struct drm_modeset_acquire_ctx *ctx);
72 
73 extern void gma_crtc_save(struct drm_crtc *crtc);
74 extern void gma_crtc_restore(struct drm_crtc *crtc);
75 
76 extern const struct drm_crtc_funcs gma_crtc_funcs;
77 
78 extern void gma_encoder_prepare(struct drm_encoder *encoder);
79 extern void gma_encoder_commit(struct drm_encoder *encoder);
80 extern void gma_encoder_destroy(struct drm_encoder *encoder);
81 
82 /* Common clock related functions */
83 extern const struct gma_limit_t *gma_limit(struct drm_crtc *crtc, int refclk);
84 extern bool gma_pll_is_valid(struct drm_crtc *crtc,
85 			     const struct gma_limit_t *limit,
86 			     struct gma_clock_t *clock);
87 extern bool gma_find_best_pll(const struct gma_limit_t *limit,
88 			      struct drm_crtc *crtc, int target, int refclk,
89 			      struct gma_clock_t *best_clock);
90 #endif
91