psb_intel_drv.h 9.2 KB

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