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 27 struct 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 39 struct gma_range_t { 40 int min, max; 41 }; 42 43 struct gma_p2_t { 44 int dot_limit; 45 int p2_slow, p2_fast; 46 }; 47 48 struct 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 56 struct 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 */ 65 extern bool gma_pipe_has_type(struct drm_crtc *crtc, int type); 66 extern void gma_wait_for_vblank(struct drm_device *dev); 67 extern int gma_pipe_set_base(struct drm_crtc *crtc, int x, int y, 68 struct drm_framebuffer *old_fb); 69 extern 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); 73 extern int gma_crtc_cursor_move(struct drm_crtc *crtc, int x, int y); 74 extern void gma_crtc_load_lut(struct drm_crtc *crtc); 75 extern void gma_crtc_gamma_set(struct drm_crtc *crtc, u16 *red, u16 *green, 76 u16 *blue, u32 start, u32 size); 77 extern void gma_crtc_dpms(struct drm_crtc *crtc, int mode); 78 extern bool gma_crtc_mode_fixup(struct drm_crtc *crtc, 79 const struct drm_display_mode *mode, 80 struct drm_display_mode *adjusted_mode); 81 extern void gma_crtc_prepare(struct drm_crtc *crtc); 82 extern void gma_crtc_commit(struct drm_crtc *crtc); 83 extern void gma_crtc_disable(struct drm_crtc *crtc); 84 extern void gma_crtc_destroy(struct drm_crtc *crtc); 85 extern int gma_crtc_set_config(struct drm_mode_set *set); 86 87 extern void gma_crtc_save(struct drm_crtc *crtc); 88 extern void gma_crtc_restore(struct drm_crtc *crtc); 89 90 extern void gma_encoder_prepare(struct drm_encoder *encoder); 91 extern void gma_encoder_commit(struct drm_encoder *encoder); 92 extern void gma_encoder_destroy(struct drm_encoder *encoder); 93 extern 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 */ 98 extern const struct gma_limit_t *gma_limit(struct drm_crtc *crtc, int refclk); 99 extern void gma_clock(int refclk, struct gma_clock_t *clock); 100 extern bool gma_pll_is_valid(struct drm_crtc *crtc, 101 const struct gma_limit_t *limit, 102 struct gma_clock_t *clock); 103 extern 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