1/*
2 * Copyright �� 2006-2011 Intel Corporation
3 *
4 * This program is free software; you can redistribute it and/or modify it
5 * under the terms and conditions of the GNU General Public License,
6 * version 2, as published by the Free Software Foundation.
7 *
8 * This program is distributed in the hope it will be useful, but WITHOUT
9 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
10 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
11 * more details.
12 *
13 * You should have received a copy of the GNU General Public License along with
14 * this program; if not, write to the Free Software Foundation, Inc.,
15 * 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
16 *
17 * Authors:
18 *	Eric Anholt <eric@anholt.net>
19 *	Patrik Jakobsson <patrik.r.jakobsson@gmail.com>
20 */
21
22#ifndef _GMA_DISPLAY_H_
23#define _GMA_DISPLAY_H_
24
25#include <linux/pm_runtime.h>
26
27struct gma_clock_t {
28	/* given values */
29	int n;
30	int m1, m2;
31	int p1, p2;
32	/* derived values */
33	int dot;
34	int vco;
35	int m;
36	int p;
37};
38
39struct gma_range_t {
40	int min, max;
41};
42
43struct gma_p2_t {
44	int dot_limit;
45	int p2_slow, p2_fast;
46};
47
48struct gma_limit_t {
49	struct gma_range_t dot, vco, n, m, m1, m2, p, p1;
50	struct gma_p2_t p2;
51	bool (*find_pll)(const struct gma_limit_t *, struct drm_crtc *,
52			 int target, int refclk,
53			 struct gma_clock_t *best_clock);
54};
55
56struct gma_clock_funcs {
57	void (*clock)(int refclk, struct gma_clock_t *clock);
58	const struct gma_limit_t *(*limit)(struct drm_crtc *crtc, int refclk);
59	bool (*pll_is_valid)(struct drm_crtc *crtc,
60			     const struct gma_limit_t *limit,
61			     struct gma_clock_t *clock);
62};
63
64/* Common pipe related functions */
65extern bool gma_pipe_has_type(struct drm_crtc *crtc, int type);
66extern void gma_wait_for_vblank(struct drm_device *dev);
67extern int gma_pipe_set_base(struct drm_crtc *crtc, int x, int y,
68			     struct drm_framebuffer *old_fb);
69extern int gma_crtc_cursor_set(struct drm_crtc *crtc,
70			       struct drm_file *file_priv,
71			       uint32_t handle,
72			       uint32_t width, uint32_t height);
73extern int gma_crtc_cursor_move(struct drm_crtc *crtc, int x, int y);
74extern void gma_crtc_load_lut(struct drm_crtc *crtc);
75extern void gma_crtc_gamma_set(struct drm_crtc *crtc, u16 *red, u16 *green,
76			       u16 *blue, u32 start, u32 size);
77extern void gma_crtc_dpms(struct drm_crtc *crtc, int mode);
78extern bool gma_crtc_mode_fixup(struct drm_crtc *crtc,
79				const struct drm_display_mode *mode,
80				struct drm_display_mode *adjusted_mode);
81extern void gma_crtc_prepare(struct drm_crtc *crtc);
82extern void gma_crtc_commit(struct drm_crtc *crtc);
83extern void gma_crtc_disable(struct drm_crtc *crtc);
84extern void gma_crtc_destroy(struct drm_crtc *crtc);
85extern int gma_crtc_set_config(struct drm_mode_set *set);
86
87extern void gma_crtc_save(struct drm_crtc *crtc);
88extern void gma_crtc_restore(struct drm_crtc *crtc);
89
90extern void gma_encoder_prepare(struct drm_encoder *encoder);
91extern void gma_encoder_commit(struct drm_encoder *encoder);
92extern void gma_encoder_destroy(struct drm_encoder *encoder);
93extern bool gma_encoder_mode_fixup(struct drm_encoder *encoder,
94				   const struct drm_display_mode *mode,
95				   struct drm_display_mode *adjusted_mode);
96
97/* Common clock related functions */
98extern const struct gma_limit_t *gma_limit(struct drm_crtc *crtc, int refclk);
99extern void gma_clock(int refclk, struct gma_clock_t *clock);
100extern bool gma_pll_is_valid(struct drm_crtc *crtc,
101			     const struct gma_limit_t *limit,
102			     struct gma_clock_t *clock);
103extern bool gma_find_best_pll(const struct gma_limit_t *limit,
104			      struct drm_crtc *crtc, int target, int refclk,
105			      struct gma_clock_t *best_clock);
106#endif
107