1a61127c2SThomas Gleixner /* SPDX-License-Identifier: GPL-2.0-only */ 25ea75e0fSPatrik Jakobsson /* 35ea75e0fSPatrik Jakobsson * Copyright © 2006-2011 Intel Corporation 45ea75e0fSPatrik Jakobsson * 55ea75e0fSPatrik Jakobsson * Authors: 65ea75e0fSPatrik Jakobsson * Eric Anholt <eric@anholt.net> 75ea75e0fSPatrik Jakobsson * Patrik Jakobsson <patrik.r.jakobsson@gmail.com> 85ea75e0fSPatrik Jakobsson */ 95ea75e0fSPatrik Jakobsson 105ea75e0fSPatrik Jakobsson #ifndef _GMA_DISPLAY_H_ 115ea75e0fSPatrik Jakobsson #define _GMA_DISPLAY_H_ 125ea75e0fSPatrik Jakobsson 13924cb5ffSPatrik Jakobsson #include <linux/pm_runtime.h> 14f76c22ceSPaul Kocialkowski #include <drm/drm_vblank.h> 15924cb5ffSPatrik Jakobsson 165ffa31edSSam Ravnborg struct drm_encoder; 175ffa31edSSam Ravnborg struct drm_mode_set; 185ffa31edSSam Ravnborg 195ea75e0fSPatrik Jakobsson struct gma_clock_t { 205ea75e0fSPatrik Jakobsson /* given values */ 215ea75e0fSPatrik Jakobsson int n; 225ea75e0fSPatrik Jakobsson int m1, m2; 235ea75e0fSPatrik Jakobsson int p1, p2; 245ea75e0fSPatrik Jakobsson /* derived values */ 255ea75e0fSPatrik Jakobsson int dot; 265ea75e0fSPatrik Jakobsson int vco; 275ea75e0fSPatrik Jakobsson int m; 285ea75e0fSPatrik Jakobsson int p; 295ea75e0fSPatrik Jakobsson }; 305ea75e0fSPatrik Jakobsson 315ea75e0fSPatrik Jakobsson struct gma_range_t { 325ea75e0fSPatrik Jakobsson int min, max; 335ea75e0fSPatrik Jakobsson }; 345ea75e0fSPatrik Jakobsson 355ea75e0fSPatrik Jakobsson struct gma_p2_t { 365ea75e0fSPatrik Jakobsson int dot_limit; 375ea75e0fSPatrik Jakobsson int p2_slow, p2_fast; 385ea75e0fSPatrik Jakobsson }; 395ea75e0fSPatrik Jakobsson 405ea75e0fSPatrik Jakobsson struct gma_limit_t { 415ea75e0fSPatrik Jakobsson struct gma_range_t dot, vco, n, m, m1, m2, p, p1; 425ea75e0fSPatrik Jakobsson struct gma_p2_t p2; 435ea75e0fSPatrik Jakobsson bool (*find_pll)(const struct gma_limit_t *, struct drm_crtc *, 445ea75e0fSPatrik Jakobsson int target, int refclk, 455ea75e0fSPatrik Jakobsson struct gma_clock_t *best_clock); 465ea75e0fSPatrik Jakobsson }; 475ea75e0fSPatrik Jakobsson 485ea75e0fSPatrik Jakobsson struct gma_clock_funcs { 495ea75e0fSPatrik Jakobsson void (*clock)(int refclk, struct gma_clock_t *clock); 505ea75e0fSPatrik Jakobsson const struct gma_limit_t *(*limit)(struct drm_crtc *crtc, int refclk); 515ea75e0fSPatrik Jakobsson bool (*pll_is_valid)(struct drm_crtc *crtc, 525ea75e0fSPatrik Jakobsson const struct gma_limit_t *limit, 535ea75e0fSPatrik Jakobsson struct gma_clock_t *clock); 545ea75e0fSPatrik Jakobsson }; 555ea75e0fSPatrik Jakobsson 565ea75e0fSPatrik Jakobsson /* Common pipe related functions */ 575ea75e0fSPatrik Jakobsson extern bool gma_pipe_has_type(struct drm_crtc *crtc, int type); 582eff0b33SPatrik Jakobsson extern void gma_wait_for_vblank(struct drm_device *dev); 592eff0b33SPatrik Jakobsson extern int gma_pipe_set_base(struct drm_crtc *crtc, int x, int y, 602eff0b33SPatrik Jakobsson struct drm_framebuffer *old_fb); 612eff0b33SPatrik Jakobsson extern void gma_crtc_load_lut(struct drm_crtc *crtc); 622eff0b33SPatrik Jakobsson extern void gma_crtc_dpms(struct drm_crtc *crtc, int mode); 632eff0b33SPatrik Jakobsson extern void gma_crtc_prepare(struct drm_crtc *crtc); 642eff0b33SPatrik Jakobsson extern void gma_crtc_commit(struct drm_crtc *crtc); 652eff0b33SPatrik Jakobsson extern void gma_crtc_disable(struct drm_crtc *crtc); 662eff0b33SPatrik Jakobsson extern void gma_crtc_destroy(struct drm_crtc *crtc); 67f76c22ceSPaul Kocialkowski extern int gma_crtc_page_flip(struct drm_crtc *crtc, 68f76c22ceSPaul Kocialkowski struct drm_framebuffer *fb, 69f76c22ceSPaul Kocialkowski struct drm_pending_vblank_event *event, 70f76c22ceSPaul Kocialkowski uint32_t page_flip_flags, 71f76c22ceSPaul Kocialkowski struct drm_modeset_acquire_ctx *ctx); 725ea75e0fSPatrik Jakobsson 732e775700SPatrik Jakobsson extern void gma_crtc_save(struct drm_crtc *crtc); 742e775700SPatrik Jakobsson extern void gma_crtc_restore(struct drm_crtc *crtc); 752e775700SPatrik Jakobsson 76*a29c6f88SPatrik Jakobsson extern const struct drm_crtc_funcs gma_crtc_funcs; 77*a29c6f88SPatrik Jakobsson 7859345847SPatrik Jakobsson extern void gma_encoder_prepare(struct drm_encoder *encoder); 7959345847SPatrik Jakobsson extern void gma_encoder_commit(struct drm_encoder *encoder); 8059345847SPatrik Jakobsson extern void gma_encoder_destroy(struct drm_encoder *encoder); 8159345847SPatrik Jakobsson 825ea75e0fSPatrik Jakobsson /* Common clock related functions */ 835ea75e0fSPatrik Jakobsson extern const struct gma_limit_t *gma_limit(struct drm_crtc *crtc, int refclk); 845ea75e0fSPatrik Jakobsson extern void gma_clock(int refclk, struct gma_clock_t *clock); 855ea75e0fSPatrik Jakobsson extern bool gma_pll_is_valid(struct drm_crtc *crtc, 865ea75e0fSPatrik Jakobsson const struct gma_limit_t *limit, 875ea75e0fSPatrik Jakobsson struct gma_clock_t *clock); 885ea75e0fSPatrik Jakobsson extern bool gma_find_best_pll(const struct gma_limit_t *limit, 895ea75e0fSPatrik Jakobsson struct drm_crtc *crtc, int target, int refclk, 905ea75e0fSPatrik Jakobsson struct gma_clock_t *best_clock); 915ea75e0fSPatrik Jakobsson #endif 92