psb_intel_drv.h 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228
  1. /*
  2. * Copyright (c) 2009-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. */
  18. #ifndef __INTEL_DRV_H__
  19. #define __INTEL_DRV_H__
  20. #include <linux/i2c.h>
  21. #include <linux/i2c-algo-bit.h>
  22. #include <drm/drm_crtc.h>
  23. #include <drm/drm_crtc_helper.h>
  24. #include <linux/gpio.h>
  25. /*
  26. * Display related stuff
  27. */
  28. /* store information about an Ixxx DVO */
  29. /* The i830->i865 use multiple DVOs with multiple i2cs */
  30. /* the i915, i945 have a single sDVO i2c bus - which is different */
  31. #define MAX_OUTPUTS 6
  32. /* maximum connectors per crtcs in the mode set */
  33. #define INTELFB_CONN_LIMIT 4
  34. #define INTEL_I2C_BUS_DVO 1
  35. #define INTEL_I2C_BUS_SDVO 2
  36. /* these are outputs from the chip - integrated only
  37. * external chips are via DVO or SDVO output */
  38. #define INTEL_OUTPUT_UNUSED 0
  39. #define INTEL_OUTPUT_ANALOG 1
  40. #define INTEL_OUTPUT_DVO 2
  41. #define INTEL_OUTPUT_SDVO 3
  42. #define INTEL_OUTPUT_LVDS 4
  43. #define INTEL_OUTPUT_TVOUT 5
  44. #define INTEL_OUTPUT_HDMI 6
  45. #define INTEL_OUTPUT_MIPI 7
  46. #define INTEL_OUTPUT_MIPI2 8
  47. #define INTEL_DVO_CHIP_NONE 0
  48. #define INTEL_DVO_CHIP_LVDS 1
  49. #define INTEL_DVO_CHIP_TMDS 2
  50. #define INTEL_DVO_CHIP_TVOUT 4
  51. /*
  52. * Hold information useally put on the device driver privates here,
  53. * since it needs to be shared across multiple of devices drivers privates.
  54. */
  55. struct psb_intel_mode_device {
  56. /*
  57. * Abstracted memory manager operations
  58. */
  59. size_t(*bo_offset) (struct drm_device *dev, void *bo);
  60. /*
  61. * Cursor (Can go ?)
  62. */
  63. int cursor_needs_physical;
  64. /*
  65. * LVDS info
  66. */
  67. int backlight_duty_cycle; /* restore backlight to this value */
  68. bool panel_wants_dither;
  69. struct drm_display_mode *panel_fixed_mode;
  70. struct drm_display_mode *panel_fixed_mode2;
  71. struct drm_display_mode *vbt_mode; /* if any */
  72. uint32_t saveBLC_PWM_CTL;
  73. };
  74. struct psb_intel_i2c_chan {
  75. /* for getting at dev. private (mmio etc.) */
  76. struct drm_device *drm_dev;
  77. u32 reg; /* GPIO reg */
  78. struct i2c_adapter adapter;
  79. struct i2c_algo_bit_data algo;
  80. u8 slave_addr;
  81. };
  82. struct psb_intel_output {
  83. struct drm_connector base;
  84. struct drm_encoder enc;
  85. int type;
  86. struct psb_intel_i2c_chan *i2c_bus; /* for control functions */
  87. struct psb_intel_i2c_chan *ddc_bus; /* for DDC only stuff */
  88. bool load_detect_temp;
  89. void *dev_priv;
  90. struct psb_intel_mode_device *mode_dev;
  91. struct i2c_adapter *hdmi_i2c_adapter; /* for control functions */
  92. };
  93. struct psb_intel_crtc_state {
  94. uint32_t saveDSPCNTR;
  95. uint32_t savePIPECONF;
  96. uint32_t savePIPESRC;
  97. uint32_t saveDPLL;
  98. uint32_t saveFP0;
  99. uint32_t saveFP1;
  100. uint32_t saveHTOTAL;
  101. uint32_t saveHBLANK;
  102. uint32_t saveHSYNC;
  103. uint32_t saveVTOTAL;
  104. uint32_t saveVBLANK;
  105. uint32_t saveVSYNC;
  106. uint32_t saveDSPSTRIDE;
  107. uint32_t saveDSPSIZE;
  108. uint32_t saveDSPPOS;
  109. uint32_t saveDSPBASE;
  110. uint32_t savePalette[256];
  111. };
  112. struct psb_intel_crtc {
  113. struct drm_crtc base;
  114. int pipe;
  115. int plane;
  116. uint32_t cursor_addr;
  117. u8 lut_r[256], lut_g[256], lut_b[256];
  118. u8 lut_adj[256];
  119. struct psb_intel_framebuffer *fbdev_fb;
  120. /* a mode_set for fbdev users on this crtc */
  121. struct drm_mode_set mode_set;
  122. /* GEM object that holds our cursor */
  123. struct drm_gem_object *cursor_obj;
  124. struct drm_display_mode saved_mode;
  125. struct drm_display_mode saved_adjusted_mode;
  126. struct psb_intel_mode_device *mode_dev;
  127. /*crtc mode setting flags*/
  128. u32 mode_flags;
  129. /* Saved Crtc HW states */
  130. struct psb_intel_crtc_state *crtc_state;
  131. };
  132. #define to_psb_intel_crtc(x) \
  133. container_of(x, struct psb_intel_crtc, base)
  134. #define to_psb_intel_output(x) \
  135. container_of(x, struct psb_intel_output, base)
  136. #define enc_to_psb_intel_output(x) \
  137. container_of(x, struct psb_intel_output, enc)
  138. #define to_psb_intel_framebuffer(x) \
  139. container_of(x, struct psb_intel_framebuffer, base)
  140. struct psb_intel_i2c_chan *psb_intel_i2c_create(struct drm_device *dev,
  141. const u32 reg, const char *name);
  142. void psb_intel_i2c_destroy(struct psb_intel_i2c_chan *chan);
  143. int psb_intel_ddc_get_modes(struct psb_intel_output *psb_intel_output);
  144. extern bool psb_intel_ddc_probe(struct psb_intel_output *psb_intel_output);
  145. extern void psb_intel_crtc_init(struct drm_device *dev, int pipe,
  146. struct psb_intel_mode_device *mode_dev);
  147. extern void psb_intel_crt_init(struct drm_device *dev);
  148. extern void psb_intel_sdvo_init(struct drm_device *dev, int output_device);
  149. extern void psb_intel_dvo_init(struct drm_device *dev);
  150. extern void psb_intel_tv_init(struct drm_device *dev);
  151. extern void psb_intel_lvds_init(struct drm_device *dev,
  152. struct psb_intel_mode_device *mode_dev);
  153. extern void psb_intel_lvds_set_brightness(struct drm_device *dev, int level);
  154. extern void oaktrail_lvds_init(struct drm_device *dev,
  155. struct psb_intel_mode_device *mode_dev);
  156. extern void oaktrail_wait_for_INTR_PKT_SENT(struct drm_device *dev);
  157. extern void oaktrail_dsi_init(struct drm_device *dev,
  158. struct psb_intel_mode_device *mode_dev);
  159. extern void mid_dsi_init(struct drm_device *dev,
  160. struct psb_intel_mode_device *mode_dev, int dsi_num);
  161. extern void psb_intel_crtc_load_lut(struct drm_crtc *crtc);
  162. extern void psb_intel_encoder_prepare(struct drm_encoder *encoder);
  163. extern void psb_intel_encoder_commit(struct drm_encoder *encoder);
  164. extern struct drm_encoder *psb_intel_best_encoder(struct drm_connector
  165. *connector);
  166. extern struct drm_display_mode *psb_intel_crtc_mode_get(struct drm_device *dev,
  167. struct drm_crtc *crtc);
  168. extern void psb_intel_wait_for_vblank(struct drm_device *dev);
  169. extern int psb_intel_get_pipe_from_crtc_id(struct drm_device *dev, void *data,
  170. struct drm_file *file_priv);
  171. extern struct drm_crtc *psb_intel_get_crtc_from_pipe(struct drm_device *dev,
  172. int pipe);
  173. extern struct drm_connector *psb_intel_sdvo_find(struct drm_device *dev,
  174. int sdvoB);
  175. extern int psb_intel_sdvo_supports_hotplug(struct drm_connector *connector);
  176. extern void psb_intel_sdvo_set_hotplug(struct drm_connector *connector,
  177. int enable);
  178. extern int intelfb_probe(struct drm_device *dev);
  179. extern int intelfb_remove(struct drm_device *dev,
  180. struct drm_framebuffer *fb);
  181. extern struct drm_framebuffer *psb_intel_framebuffer_create(struct drm_device
  182. *dev, struct
  183. drm_mode_fb_cmd
  184. *mode_cmd,
  185. void *mm_private);
  186. extern bool psb_intel_lvds_mode_fixup(struct drm_encoder *encoder,
  187. struct drm_display_mode *mode,
  188. struct drm_display_mode *adjusted_mode);
  189. extern int psb_intel_lvds_mode_valid(struct drm_connector *connector,
  190. struct drm_display_mode *mode);
  191. extern int psb_intel_lvds_set_property(struct drm_connector *connector,
  192. struct drm_property *property,
  193. uint64_t value);
  194. extern void psb_intel_lvds_destroy(struct drm_connector *connector);
  195. extern const struct drm_encoder_funcs psb_intel_lvds_enc_funcs;
  196. #endif /* __INTEL_DRV_H__ */