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 
15 struct gma_clock_t {
16 	/* given values */
17 	int n;
18 	int m1, m2;
19 	int p1, p2;
20 	/* derived values */
21 	int dot;
22 	int vco;
23 	int m;
24 	int p;
25 };
26 
27 struct gma_range_t {
28 	int min, max;
29 };
30 
31 struct gma_p2_t {
32 	int dot_limit;
33 	int p2_slow, p2_fast;
34 };
35 
36 struct gma_limit_t {
37 	struct gma_range_t dot, vco, n, m, m1, m2, p, p1;
38 	struct gma_p2_t p2;
39 	bool (*find_pll)(const struct gma_limit_t *, struct drm_crtc *,
40 			 int target, int refclk,
41 			 struct gma_clock_t *best_clock);
42 };
43 
44 struct gma_clock_funcs {
45 	void (*clock)(int refclk, struct gma_clock_t *clock);
46 	const struct gma_limit_t *(*limit)(struct drm_crtc *crtc, int refclk);
47 	bool (*pll_is_valid)(struct drm_crtc *crtc,
48 			     const struct gma_limit_t *limit,
49 			     struct gma_clock_t *clock);
50 };
51 
52 /* Common pipe related functions */
53 extern bool gma_pipe_has_type(struct drm_crtc *crtc, int type);
54 extern void gma_wait_for_vblank(struct drm_device *dev);
55 extern int gma_pipe_set_base(struct drm_crtc *crtc, int x, int y,
56 			     struct drm_framebuffer *old_fb);
57 extern int gma_crtc_cursor_set(struct drm_crtc *crtc,
58 			       struct drm_file *file_priv,
59 			       uint32_t handle,
60 			       uint32_t width, uint32_t height);
61 extern int gma_crtc_cursor_move(struct drm_crtc *crtc, int x, int y);
62 extern void gma_crtc_load_lut(struct drm_crtc *crtc);
63 extern int gma_crtc_gamma_set(struct drm_crtc *crtc, u16 *red, u16 *green,
64 			      u16 *blue, u32 size,
65 			      struct drm_modeset_acquire_ctx *ctx);
66 extern void gma_crtc_dpms(struct drm_crtc *crtc, int mode);
67 extern void gma_crtc_prepare(struct drm_crtc *crtc);
68 extern void gma_crtc_commit(struct drm_crtc *crtc);
69 extern void gma_crtc_disable(struct drm_crtc *crtc);
70 extern void gma_crtc_destroy(struct drm_crtc *crtc);
71 extern int gma_crtc_set_config(struct drm_mode_set *set,
72 			       struct drm_modeset_acquire_ctx *ctx);
73 
74 extern void gma_crtc_save(struct drm_crtc *crtc);
75 extern void gma_crtc_restore(struct drm_crtc *crtc);
76 
77 extern void gma_encoder_prepare(struct drm_encoder *encoder);
78 extern void gma_encoder_commit(struct drm_encoder *encoder);
79 extern void gma_encoder_destroy(struct drm_encoder *encoder);
80 
81 /* Common clock related functions */
82 extern const struct gma_limit_t *gma_limit(struct drm_crtc *crtc, int refclk);
83 extern void gma_clock(int refclk, struct gma_clock_t *clock);
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