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