18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0-only */
28c2ecf20Sopenharmony_ci/*
38c2ecf20Sopenharmony_ci * Copyright © 2006-2011 Intel Corporation
48c2ecf20Sopenharmony_ci *
58c2ecf20Sopenharmony_ci * Authors:
68c2ecf20Sopenharmony_ci *	Eric Anholt <eric@anholt.net>
78c2ecf20Sopenharmony_ci *	Patrik Jakobsson <patrik.r.jakobsson@gmail.com>
88c2ecf20Sopenharmony_ci */
98c2ecf20Sopenharmony_ci
108c2ecf20Sopenharmony_ci#ifndef _GMA_DISPLAY_H_
118c2ecf20Sopenharmony_ci#define _GMA_DISPLAY_H_
128c2ecf20Sopenharmony_ci
138c2ecf20Sopenharmony_ci#include <linux/pm_runtime.h>
148c2ecf20Sopenharmony_ci#include <drm/drm_vblank.h>
158c2ecf20Sopenharmony_ci
168c2ecf20Sopenharmony_cistruct drm_encoder;
178c2ecf20Sopenharmony_cistruct drm_mode_set;
188c2ecf20Sopenharmony_ci
198c2ecf20Sopenharmony_cistruct gma_clock_t {
208c2ecf20Sopenharmony_ci	/* given values */
218c2ecf20Sopenharmony_ci	int n;
228c2ecf20Sopenharmony_ci	int m1, m2;
238c2ecf20Sopenharmony_ci	int p1, p2;
248c2ecf20Sopenharmony_ci	/* derived values */
258c2ecf20Sopenharmony_ci	int dot;
268c2ecf20Sopenharmony_ci	int vco;
278c2ecf20Sopenharmony_ci	int m;
288c2ecf20Sopenharmony_ci	int p;
298c2ecf20Sopenharmony_ci};
308c2ecf20Sopenharmony_ci
318c2ecf20Sopenharmony_cistruct gma_range_t {
328c2ecf20Sopenharmony_ci	int min, max;
338c2ecf20Sopenharmony_ci};
348c2ecf20Sopenharmony_ci
358c2ecf20Sopenharmony_cistruct gma_p2_t {
368c2ecf20Sopenharmony_ci	int dot_limit;
378c2ecf20Sopenharmony_ci	int p2_slow, p2_fast;
388c2ecf20Sopenharmony_ci};
398c2ecf20Sopenharmony_ci
408c2ecf20Sopenharmony_cistruct gma_limit_t {
418c2ecf20Sopenharmony_ci	struct gma_range_t dot, vco, n, m, m1, m2, p, p1;
428c2ecf20Sopenharmony_ci	struct gma_p2_t p2;
438c2ecf20Sopenharmony_ci	bool (*find_pll)(const struct gma_limit_t *, struct drm_crtc *,
448c2ecf20Sopenharmony_ci			 int target, int refclk,
458c2ecf20Sopenharmony_ci			 struct gma_clock_t *best_clock);
468c2ecf20Sopenharmony_ci};
478c2ecf20Sopenharmony_ci
488c2ecf20Sopenharmony_cistruct gma_clock_funcs {
498c2ecf20Sopenharmony_ci	void (*clock)(int refclk, struct gma_clock_t *clock);
508c2ecf20Sopenharmony_ci	const struct gma_limit_t *(*limit)(struct drm_crtc *crtc, int refclk);
518c2ecf20Sopenharmony_ci	bool (*pll_is_valid)(struct drm_crtc *crtc,
528c2ecf20Sopenharmony_ci			     const struct gma_limit_t *limit,
538c2ecf20Sopenharmony_ci			     struct gma_clock_t *clock);
548c2ecf20Sopenharmony_ci};
558c2ecf20Sopenharmony_ci
568c2ecf20Sopenharmony_ci/* Common pipe related functions */
578c2ecf20Sopenharmony_ciextern bool gma_pipe_has_type(struct drm_crtc *crtc, int type);
588c2ecf20Sopenharmony_ciextern void gma_wait_for_vblank(struct drm_device *dev);
598c2ecf20Sopenharmony_ciextern int gma_pipe_set_base(struct drm_crtc *crtc, int x, int y,
608c2ecf20Sopenharmony_ci			     struct drm_framebuffer *old_fb);
618c2ecf20Sopenharmony_ciextern int gma_crtc_cursor_set(struct drm_crtc *crtc,
628c2ecf20Sopenharmony_ci			       struct drm_file *file_priv,
638c2ecf20Sopenharmony_ci			       uint32_t handle,
648c2ecf20Sopenharmony_ci			       uint32_t width, uint32_t height);
658c2ecf20Sopenharmony_ciextern int gma_crtc_cursor_move(struct drm_crtc *crtc, int x, int y);
668c2ecf20Sopenharmony_ciextern void gma_crtc_load_lut(struct drm_crtc *crtc);
678c2ecf20Sopenharmony_ciextern int gma_crtc_gamma_set(struct drm_crtc *crtc, u16 *red, u16 *green,
688c2ecf20Sopenharmony_ci			      u16 *blue, u32 size,
698c2ecf20Sopenharmony_ci			      struct drm_modeset_acquire_ctx *ctx);
708c2ecf20Sopenharmony_ciextern void gma_crtc_dpms(struct drm_crtc *crtc, int mode);
718c2ecf20Sopenharmony_ciextern void gma_crtc_prepare(struct drm_crtc *crtc);
728c2ecf20Sopenharmony_ciextern void gma_crtc_commit(struct drm_crtc *crtc);
738c2ecf20Sopenharmony_ciextern void gma_crtc_disable(struct drm_crtc *crtc);
748c2ecf20Sopenharmony_ciextern void gma_crtc_destroy(struct drm_crtc *crtc);
758c2ecf20Sopenharmony_ciextern int gma_crtc_page_flip(struct drm_crtc *crtc,
768c2ecf20Sopenharmony_ci			      struct drm_framebuffer *fb,
778c2ecf20Sopenharmony_ci			      struct drm_pending_vblank_event *event,
788c2ecf20Sopenharmony_ci			      uint32_t page_flip_flags,
798c2ecf20Sopenharmony_ci			      struct drm_modeset_acquire_ctx *ctx);
808c2ecf20Sopenharmony_ciextern int gma_crtc_set_config(struct drm_mode_set *set,
818c2ecf20Sopenharmony_ci			       struct drm_modeset_acquire_ctx *ctx);
828c2ecf20Sopenharmony_ci
838c2ecf20Sopenharmony_ciextern void gma_crtc_save(struct drm_crtc *crtc);
848c2ecf20Sopenharmony_ciextern void gma_crtc_restore(struct drm_crtc *crtc);
858c2ecf20Sopenharmony_ci
868c2ecf20Sopenharmony_ciextern void gma_encoder_prepare(struct drm_encoder *encoder);
878c2ecf20Sopenharmony_ciextern void gma_encoder_commit(struct drm_encoder *encoder);
888c2ecf20Sopenharmony_ciextern void gma_encoder_destroy(struct drm_encoder *encoder);
898c2ecf20Sopenharmony_ci
908c2ecf20Sopenharmony_ci/* Common clock related functions */
918c2ecf20Sopenharmony_ciextern const struct gma_limit_t *gma_limit(struct drm_crtc *crtc, int refclk);
928c2ecf20Sopenharmony_ciextern void gma_clock(int refclk, struct gma_clock_t *clock);
938c2ecf20Sopenharmony_ciextern bool gma_pll_is_valid(struct drm_crtc *crtc,
948c2ecf20Sopenharmony_ci			     const struct gma_limit_t *limit,
958c2ecf20Sopenharmony_ci			     struct gma_clock_t *clock);
968c2ecf20Sopenharmony_ciextern bool gma_find_best_pll(const struct gma_limit_t *limit,
978c2ecf20Sopenharmony_ci			      struct drm_crtc *crtc, int target, int refclk,
988c2ecf20Sopenharmony_ci			      struct gma_clock_t *best_clock);
998c2ecf20Sopenharmony_ci#endif
100