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 drm_encoder; 28 struct drm_mode_set; 29 30 struct gma_clock_t { 31 /* given values */ 32 int n; 33 int m1, m2; 34 int p1, p2; 35 /* derived values */ 36 int dot; 37 int vco; 38 int m; 39 int p; 40 }; 41 42 struct gma_range_t { 43 int min, max; 44 }; 45 46 struct gma_p2_t { 47 int dot_limit; 48 int p2_slow, p2_fast; 49 }; 50 51 struct gma_limit_t { 52 struct gma_range_t dot, vco, n, m, m1, m2, p, p1; 53 struct gma_p2_t p2; 54 bool (*find_pll)(const struct gma_limit_t *, struct drm_crtc *, 55 int target, int refclk, 56 struct gma_clock_t *best_clock); 57 }; 58 59 struct gma_clock_funcs { 60 void (*clock)(int refclk, struct gma_clock_t *clock); 61 const struct gma_limit_t *(*limit)(struct drm_crtc *crtc, int refclk); 62 bool (*pll_is_valid)(struct drm_crtc *crtc, 63 const struct gma_limit_t *limit, 64 struct gma_clock_t *clock); 65 }; 66 67 /* Common pipe related functions */ 68 extern bool gma_pipe_has_type(struct drm_crtc *crtc, int type); 69 extern void gma_wait_for_vblank(struct drm_device *dev); 70 extern int gma_pipe_set_base(struct drm_crtc *crtc, int x, int y, 71 struct drm_framebuffer *old_fb); 72 extern int gma_crtc_cursor_set(struct drm_crtc *crtc, 73 struct drm_file *file_priv, 74 uint32_t handle, 75 uint32_t width, uint32_t height); 76 extern int gma_crtc_cursor_move(struct drm_crtc *crtc, int x, int y); 77 extern void gma_crtc_load_lut(struct drm_crtc *crtc); 78 extern int gma_crtc_gamma_set(struct drm_crtc *crtc, u16 *red, u16 *green, 79 u16 *blue, u32 size, 80 struct drm_modeset_acquire_ctx *ctx); 81 extern void gma_crtc_dpms(struct drm_crtc *crtc, int mode); 82 extern void gma_crtc_prepare(struct drm_crtc *crtc); 83 extern void gma_crtc_commit(struct drm_crtc *crtc); 84 extern void gma_crtc_disable(struct drm_crtc *crtc); 85 extern void gma_crtc_destroy(struct drm_crtc *crtc); 86 extern int gma_crtc_set_config(struct drm_mode_set *set, 87 struct drm_modeset_acquire_ctx *ctx); 88 89 extern void gma_crtc_save(struct drm_crtc *crtc); 90 extern void gma_crtc_restore(struct drm_crtc *crtc); 91 92 extern void gma_encoder_prepare(struct drm_encoder *encoder); 93 extern void gma_encoder_commit(struct drm_encoder *encoder); 94 extern void gma_encoder_destroy(struct drm_encoder *encoder); 95 96 /* Common clock related functions */ 97 extern const struct gma_limit_t *gma_limit(struct drm_crtc *crtc, int refclk); 98 extern void gma_clock(int refclk, struct gma_clock_t *clock); 99 extern bool gma_pll_is_valid(struct drm_crtc *crtc, 100 const struct gma_limit_t *limit, 101 struct gma_clock_t *clock); 102 extern bool gma_find_best_pll(const struct gma_limit_t *limit, 103 struct drm_crtc *crtc, int target, int refclk, 104 struct gma_clock_t *best_clock); 105 #endif 106