psb_intel_drv.h 9.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290
  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. /* Intel Pipe Clone Bit */
  37. #define INTEL_HDMIB_CLONE_BIT 1
  38. #define INTEL_HDMIC_CLONE_BIT 2
  39. #define INTEL_HDMID_CLONE_BIT 3
  40. #define INTEL_HDMIE_CLONE_BIT 4
  41. #define INTEL_HDMIF_CLONE_BIT 5
  42. #define INTEL_SDVO_NON_TV_CLONE_BIT 6
  43. #define INTEL_SDVO_TV_CLONE_BIT 7
  44. #define INTEL_SDVO_LVDS_CLONE_BIT 8
  45. #define INTEL_ANALOG_CLONE_BIT 9
  46. #define INTEL_TV_CLONE_BIT 10
  47. #define INTEL_DP_B_CLONE_BIT 11
  48. #define INTEL_DP_C_CLONE_BIT 12
  49. #define INTEL_DP_D_CLONE_BIT 13
  50. #define INTEL_LVDS_CLONE_BIT 14
  51. #define INTEL_DVO_TMDS_CLONE_BIT 15
  52. #define INTEL_DVO_LVDS_CLONE_BIT 16
  53. #define INTEL_EDP_CLONE_BIT 17
  54. /* these are outputs from the chip - integrated only
  55. * external chips are via DVO or SDVO output */
  56. #define INTEL_OUTPUT_UNUSED 0
  57. #define INTEL_OUTPUT_ANALOG 1
  58. #define INTEL_OUTPUT_DVO 2
  59. #define INTEL_OUTPUT_SDVO 3
  60. #define INTEL_OUTPUT_LVDS 4
  61. #define INTEL_OUTPUT_TVOUT 5
  62. #define INTEL_OUTPUT_HDMI 6
  63. #define INTEL_OUTPUT_MIPI 7
  64. #define INTEL_OUTPUT_MIPI2 8
  65. #define INTEL_DVO_CHIP_NONE 0
  66. #define INTEL_DVO_CHIP_LVDS 1
  67. #define INTEL_DVO_CHIP_TMDS 2
  68. #define INTEL_DVO_CHIP_TVOUT 4
  69. #define INTEL_MODE_PIXEL_MULTIPLIER_SHIFT (0x0)
  70. #define INTEL_MODE_PIXEL_MULTIPLIER_MASK (0xf << INTEL_MODE_PIXEL_MULTIPLIER_SHIFT)
  71. static inline void
  72. psb_intel_mode_set_pixel_multiplier(struct drm_display_mode *mode,
  73. int multiplier)
  74. {
  75. mode->clock *= multiplier;
  76. mode->private_flags |= multiplier;
  77. }
  78. static inline int
  79. psb_intel_mode_get_pixel_multiplier(const struct drm_display_mode *mode)
  80. {
  81. return (mode->private_flags & INTEL_MODE_PIXEL_MULTIPLIER_MASK)
  82. >> INTEL_MODE_PIXEL_MULTIPLIER_SHIFT;
  83. }
  84. /*
  85. * Hold information useally put on the device driver privates here,
  86. * since it needs to be shared across multiple of devices drivers privates.
  87. */
  88. struct psb_intel_mode_device {
  89. /*
  90. * Abstracted memory manager operations
  91. */
  92. size_t(*bo_offset) (struct drm_device *dev, void *bo);
  93. /*
  94. * Cursor (Can go ?)
  95. */
  96. int cursor_needs_physical;
  97. /*
  98. * LVDS info
  99. */
  100. int backlight_duty_cycle; /* restore backlight to this value */
  101. bool panel_wants_dither;
  102. struct drm_display_mode *panel_fixed_mode;
  103. struct drm_display_mode *panel_fixed_mode2;
  104. struct drm_display_mode *vbt_mode; /* if any */
  105. uint32_t saveBLC_PWM_CTL;
  106. };
  107. struct psb_intel_i2c_chan {
  108. /* for getting at dev. private (mmio etc.) */
  109. struct drm_device *drm_dev;
  110. u32 reg; /* GPIO reg */
  111. struct i2c_adapter adapter;
  112. struct i2c_algo_bit_data algo;
  113. u8 slave_addr;
  114. };
  115. struct psb_intel_encoder {
  116. struct drm_encoder base;
  117. int type;
  118. bool needs_tv_clock;
  119. void (*hot_plug)(struct psb_intel_encoder *);
  120. int crtc_mask;
  121. int clone_mask;
  122. void *dev_priv; /* For sdvo_priv, lvds_priv, etc... */
  123. /* FIXME: Either make SDVO and LVDS store it's i2c here or give CDV it's
  124. own set of output privates */
  125. struct psb_intel_i2c_chan *i2c_bus;
  126. struct psb_intel_i2c_chan *ddc_bus;
  127. };
  128. struct psb_intel_connector {
  129. struct drm_connector base;
  130. struct psb_intel_encoder *encoder;
  131. };
  132. struct psb_intel_crtc_state {
  133. uint32_t saveDSPCNTR;
  134. uint32_t savePIPECONF;
  135. uint32_t savePIPESRC;
  136. uint32_t saveDPLL;
  137. uint32_t saveFP0;
  138. uint32_t saveFP1;
  139. uint32_t saveHTOTAL;
  140. uint32_t saveHBLANK;
  141. uint32_t saveHSYNC;
  142. uint32_t saveVTOTAL;
  143. uint32_t saveVBLANK;
  144. uint32_t saveVSYNC;
  145. uint32_t saveDSPSTRIDE;
  146. uint32_t saveDSPSIZE;
  147. uint32_t saveDSPPOS;
  148. uint32_t saveDSPBASE;
  149. uint32_t savePalette[256];
  150. };
  151. struct psb_intel_crtc {
  152. struct drm_crtc base;
  153. int pipe;
  154. int plane;
  155. uint32_t cursor_addr;
  156. u8 lut_r[256], lut_g[256], lut_b[256];
  157. u8 lut_adj[256];
  158. struct psb_intel_framebuffer *fbdev_fb;
  159. /* a mode_set for fbdev users on this crtc */
  160. struct drm_mode_set mode_set;
  161. /* GEM object that holds our cursor */
  162. struct drm_gem_object *cursor_obj;
  163. struct drm_display_mode saved_mode;
  164. struct drm_display_mode saved_adjusted_mode;
  165. struct psb_intel_mode_device *mode_dev;
  166. /*crtc mode setting flags*/
  167. u32 mode_flags;
  168. /* Saved Crtc HW states */
  169. struct psb_intel_crtc_state *crtc_state;
  170. };
  171. #define to_psb_intel_crtc(x) \
  172. container_of(x, struct psb_intel_crtc, base)
  173. #define to_psb_intel_connector(x) \
  174. container_of(x, struct psb_intel_connector, base)
  175. #define to_psb_intel_encoder(x) \
  176. container_of(x, struct psb_intel_encoder, base)
  177. #define to_psb_intel_framebuffer(x) \
  178. container_of(x, struct psb_intel_framebuffer, base)
  179. struct psb_intel_i2c_chan *psb_intel_i2c_create(struct drm_device *dev,
  180. const u32 reg, const char *name);
  181. void psb_intel_i2c_destroy(struct psb_intel_i2c_chan *chan);
  182. int psb_intel_ddc_get_modes(struct drm_connector *connector,
  183. struct i2c_adapter *adapter);
  184. extern bool psb_intel_ddc_probe(struct i2c_adapter *adapter);
  185. extern void psb_intel_crtc_init(struct drm_device *dev, int pipe,
  186. struct psb_intel_mode_device *mode_dev);
  187. extern void psb_intel_crt_init(struct drm_device *dev);
  188. extern bool psb_intel_sdvo_init(struct drm_device *dev, int output_device);
  189. extern void psb_intel_dvo_init(struct drm_device *dev);
  190. extern void psb_intel_tv_init(struct drm_device *dev);
  191. extern void psb_intel_lvds_init(struct drm_device *dev,
  192. struct psb_intel_mode_device *mode_dev);
  193. extern void psb_intel_lvds_set_brightness(struct drm_device *dev, int level);
  194. extern void oaktrail_lvds_init(struct drm_device *dev,
  195. struct psb_intel_mode_device *mode_dev);
  196. extern void oaktrail_wait_for_INTR_PKT_SENT(struct drm_device *dev);
  197. extern void oaktrail_dsi_init(struct drm_device *dev,
  198. struct psb_intel_mode_device *mode_dev);
  199. extern void mid_dsi_init(struct drm_device *dev,
  200. struct psb_intel_mode_device *mode_dev, int dsi_num);
  201. extern void psb_intel_crtc_load_lut(struct drm_crtc *crtc);
  202. extern void psb_intel_encoder_prepare(struct drm_encoder *encoder);
  203. extern void psb_intel_encoder_commit(struct drm_encoder *encoder);
  204. extern void psb_intel_encoder_destroy(struct drm_encoder *encoder);
  205. static inline struct psb_intel_encoder *psb_intel_attached_encoder(
  206. struct drm_connector *connector)
  207. {
  208. return to_psb_intel_connector(connector)->encoder;
  209. }
  210. extern void psb_intel_connector_attach_encoder(
  211. struct psb_intel_connector *connector,
  212. struct psb_intel_encoder *encoder);
  213. extern struct drm_encoder *psb_intel_best_encoder(struct drm_connector
  214. *connector);
  215. extern struct drm_display_mode *psb_intel_crtc_mode_get(struct drm_device *dev,
  216. struct drm_crtc *crtc);
  217. extern void psb_intel_wait_for_vblank(struct drm_device *dev);
  218. extern int psb_intel_get_pipe_from_crtc_id(struct drm_device *dev, void *data,
  219. struct drm_file *file_priv);
  220. extern struct drm_crtc *psb_intel_get_crtc_from_pipe(struct drm_device *dev,
  221. int pipe);
  222. extern struct drm_connector *psb_intel_sdvo_find(struct drm_device *dev,
  223. int sdvoB);
  224. extern int psb_intel_sdvo_supports_hotplug(struct drm_connector *connector);
  225. extern void psb_intel_sdvo_set_hotplug(struct drm_connector *connector,
  226. int enable);
  227. extern int intelfb_probe(struct drm_device *dev);
  228. extern int intelfb_remove(struct drm_device *dev,
  229. struct drm_framebuffer *fb);
  230. extern struct drm_framebuffer *psb_intel_framebuffer_create(struct drm_device
  231. *dev, struct
  232. drm_mode_fb_cmd
  233. *mode_cmd,
  234. void *mm_private);
  235. extern bool psb_intel_lvds_mode_fixup(struct drm_encoder *encoder,
  236. struct drm_display_mode *mode,
  237. struct drm_display_mode *adjusted_mode);
  238. extern int psb_intel_lvds_mode_valid(struct drm_connector *connector,
  239. struct drm_display_mode *mode);
  240. extern int psb_intel_lvds_set_property(struct drm_connector *connector,
  241. struct drm_property *property,
  242. uint64_t value);
  243. extern void psb_intel_lvds_destroy(struct drm_connector *connector);
  244. extern const struct drm_encoder_funcs psb_intel_lvds_enc_funcs;
  245. /* intel_gmbus.c */
  246. extern void gma_intel_i2c_reset(struct drm_device *dev);
  247. extern int gma_intel_setup_gmbus(struct drm_device *dev);
  248. extern void gma_intel_gmbus_set_speed(struct i2c_adapter *adapter, int speed);
  249. extern void gma_intel_gmbus_force_bit(struct i2c_adapter *adapter, bool force_bit);
  250. extern void gma_intel_teardown_gmbus(struct drm_device *dev);
  251. #endif /* __INTEL_DRV_H__ */