psb_intel_display.c 30 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122
  1. /*
  2. * Copyright © 2006-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. * Authors:
  18. * Eric Anholt <eric@anholt.net>
  19. */
  20. #include <linux/i2c.h>
  21. #include <linux/pm_runtime.h>
  22. #include <drm/drmP.h>
  23. #include "framebuffer.h"
  24. #include "psb_drv.h"
  25. #include "psb_intel_drv.h"
  26. #include "psb_intel_reg.h"
  27. #include "gma_display.h"
  28. #include "power.h"
  29. #define INTEL_LIMIT_I9XX_SDVO_DAC 0
  30. #define INTEL_LIMIT_I9XX_LVDS 1
  31. static const struct gma_limit_t psb_intel_limits[] = {
  32. { /* INTEL_LIMIT_I9XX_SDVO_DAC */
  33. .dot = {.min = 20000, .max = 400000},
  34. .vco = {.min = 1400000, .max = 2800000},
  35. .n = {.min = 1, .max = 6},
  36. .m = {.min = 70, .max = 120},
  37. .m1 = {.min = 8, .max = 18},
  38. .m2 = {.min = 3, .max = 7},
  39. .p = {.min = 5, .max = 80},
  40. .p1 = {.min = 1, .max = 8},
  41. .p2 = {.dot_limit = 200000, .p2_slow = 10, .p2_fast = 5},
  42. .find_pll = gma_find_best_pll,
  43. },
  44. { /* INTEL_LIMIT_I9XX_LVDS */
  45. .dot = {.min = 20000, .max = 400000},
  46. .vco = {.min = 1400000, .max = 2800000},
  47. .n = {.min = 1, .max = 6},
  48. .m = {.min = 70, .max = 120},
  49. .m1 = {.min = 8, .max = 18},
  50. .m2 = {.min = 3, .max = 7},
  51. .p = {.min = 7, .max = 98},
  52. .p1 = {.min = 1, .max = 8},
  53. /* The single-channel range is 25-112Mhz, and dual-channel
  54. * is 80-224Mhz. Prefer single channel as much as possible.
  55. */
  56. .p2 = {.dot_limit = 112000, .p2_slow = 14, .p2_fast = 7},
  57. .find_pll = gma_find_best_pll,
  58. },
  59. };
  60. static const struct gma_limit_t *psb_intel_limit(struct drm_crtc *crtc,
  61. int refclk)
  62. {
  63. const struct gma_limit_t *limit;
  64. if (gma_pipe_has_type(crtc, INTEL_OUTPUT_LVDS))
  65. limit = &psb_intel_limits[INTEL_LIMIT_I9XX_LVDS];
  66. else
  67. limit = &psb_intel_limits[INTEL_LIMIT_I9XX_SDVO_DAC];
  68. return limit;
  69. }
  70. static void psb_intel_clock(int refclk, struct gma_clock_t *clock)
  71. {
  72. clock->m = 5 * (clock->m1 + 2) + (clock->m2 + 2);
  73. clock->p = clock->p1 * clock->p2;
  74. clock->vco = refclk * clock->m / (clock->n + 2);
  75. clock->dot = clock->vco / clock->p;
  76. }
  77. /**
  78. * Sets the power management mode of the pipe and plane.
  79. *
  80. * This code should probably grow support for turning the cursor off and back
  81. * on appropriately at the same time as we're turning the pipe off/on.
  82. */
  83. static void psb_intel_crtc_dpms(struct drm_crtc *crtc, int mode)
  84. {
  85. struct drm_device *dev = crtc->dev;
  86. struct drm_psb_private *dev_priv = dev->dev_private;
  87. struct psb_intel_crtc *psb_intel_crtc = to_psb_intel_crtc(crtc);
  88. int pipe = psb_intel_crtc->pipe;
  89. const struct psb_offset *map = &dev_priv->regmap[pipe];
  90. u32 temp;
  91. /* XXX: When our outputs are all unaware of DPMS modes other than off
  92. * and on, we should map those modes to DRM_MODE_DPMS_OFF in the CRTC.
  93. */
  94. switch (mode) {
  95. case DRM_MODE_DPMS_ON:
  96. case DRM_MODE_DPMS_STANDBY:
  97. case DRM_MODE_DPMS_SUSPEND:
  98. /* Enable the DPLL */
  99. temp = REG_READ(map->dpll);
  100. if ((temp & DPLL_VCO_ENABLE) == 0) {
  101. REG_WRITE(map->dpll, temp);
  102. REG_READ(map->dpll);
  103. /* Wait for the clocks to stabilize. */
  104. udelay(150);
  105. REG_WRITE(map->dpll, temp | DPLL_VCO_ENABLE);
  106. REG_READ(map->dpll);
  107. /* Wait for the clocks to stabilize. */
  108. udelay(150);
  109. REG_WRITE(map->dpll, temp | DPLL_VCO_ENABLE);
  110. REG_READ(map->dpll);
  111. /* Wait for the clocks to stabilize. */
  112. udelay(150);
  113. }
  114. /* Enable the pipe */
  115. temp = REG_READ(map->conf);
  116. if ((temp & PIPEACONF_ENABLE) == 0)
  117. REG_WRITE(map->conf, temp | PIPEACONF_ENABLE);
  118. /* Enable the plane */
  119. temp = REG_READ(map->cntr);
  120. if ((temp & DISPLAY_PLANE_ENABLE) == 0) {
  121. REG_WRITE(map->cntr,
  122. temp | DISPLAY_PLANE_ENABLE);
  123. /* Flush the plane changes */
  124. REG_WRITE(map->base, REG_READ(map->base));
  125. }
  126. psb_intel_crtc_load_lut(crtc);
  127. /* Give the overlay scaler a chance to enable
  128. * if it's on this pipe */
  129. /* psb_intel_crtc_dpms_video(crtc, true); TODO */
  130. break;
  131. case DRM_MODE_DPMS_OFF:
  132. /* Give the overlay scaler a chance to disable
  133. * if it's on this pipe */
  134. /* psb_intel_crtc_dpms_video(crtc, FALSE); TODO */
  135. /* Disable the VGA plane that we never use */
  136. REG_WRITE(VGACNTRL, VGA_DISP_DISABLE);
  137. /* Disable display plane */
  138. temp = REG_READ(map->cntr);
  139. if ((temp & DISPLAY_PLANE_ENABLE) != 0) {
  140. REG_WRITE(map->cntr,
  141. temp & ~DISPLAY_PLANE_ENABLE);
  142. /* Flush the plane changes */
  143. REG_WRITE(map->base, REG_READ(map->base));
  144. REG_READ(map->base);
  145. }
  146. /* Next, disable display pipes */
  147. temp = REG_READ(map->conf);
  148. if ((temp & PIPEACONF_ENABLE) != 0) {
  149. REG_WRITE(map->conf, temp & ~PIPEACONF_ENABLE);
  150. REG_READ(map->conf);
  151. }
  152. /* Wait for vblank for the disable to take effect. */
  153. gma_wait_for_vblank(dev);
  154. temp = REG_READ(map->dpll);
  155. if ((temp & DPLL_VCO_ENABLE) != 0) {
  156. REG_WRITE(map->dpll, temp & ~DPLL_VCO_ENABLE);
  157. REG_READ(map->dpll);
  158. }
  159. /* Wait for the clocks to turn off. */
  160. udelay(150);
  161. break;
  162. }
  163. /*Set FIFO Watermarks*/
  164. REG_WRITE(DSPARB, 0x3F3E);
  165. }
  166. void psb_intel_encoder_prepare(struct drm_encoder *encoder)
  167. {
  168. struct drm_encoder_helper_funcs *encoder_funcs =
  169. encoder->helper_private;
  170. /* lvds has its own version of prepare see psb_intel_lvds_prepare */
  171. encoder_funcs->dpms(encoder, DRM_MODE_DPMS_OFF);
  172. }
  173. void psb_intel_encoder_commit(struct drm_encoder *encoder)
  174. {
  175. struct drm_encoder_helper_funcs *encoder_funcs =
  176. encoder->helper_private;
  177. /* lvds has its own version of commit see psb_intel_lvds_commit */
  178. encoder_funcs->dpms(encoder, DRM_MODE_DPMS_ON);
  179. }
  180. void psb_intel_encoder_destroy(struct drm_encoder *encoder)
  181. {
  182. struct psb_intel_encoder *intel_encoder = to_psb_intel_encoder(encoder);
  183. drm_encoder_cleanup(encoder);
  184. kfree(intel_encoder);
  185. }
  186. /**
  187. * Return the pipe currently connected to the panel fitter,
  188. * or -1 if the panel fitter is not present or not in use
  189. */
  190. static int psb_intel_panel_fitter_pipe(struct drm_device *dev)
  191. {
  192. u32 pfit_control;
  193. pfit_control = REG_READ(PFIT_CONTROL);
  194. /* See if the panel fitter is in use */
  195. if ((pfit_control & PFIT_ENABLE) == 0)
  196. return -1;
  197. /* Must be on PIPE 1 for PSB */
  198. return 1;
  199. }
  200. static int psb_intel_crtc_mode_set(struct drm_crtc *crtc,
  201. struct drm_display_mode *mode,
  202. struct drm_display_mode *adjusted_mode,
  203. int x, int y,
  204. struct drm_framebuffer *old_fb)
  205. {
  206. struct drm_device *dev = crtc->dev;
  207. struct drm_psb_private *dev_priv = dev->dev_private;
  208. struct psb_intel_crtc *psb_intel_crtc = to_psb_intel_crtc(crtc);
  209. struct drm_crtc_helper_funcs *crtc_funcs = crtc->helper_private;
  210. int pipe = psb_intel_crtc->pipe;
  211. const struct psb_offset *map = &dev_priv->regmap[pipe];
  212. int refclk;
  213. struct gma_clock_t clock;
  214. u32 dpll = 0, fp = 0, dspcntr, pipeconf;
  215. bool ok, is_sdvo = false;
  216. bool is_lvds = false, is_tv = false;
  217. struct drm_mode_config *mode_config = &dev->mode_config;
  218. struct drm_connector *connector;
  219. const struct gma_limit_t *limit;
  220. /* No scan out no play */
  221. if (crtc->fb == NULL) {
  222. crtc_funcs->mode_set_base(crtc, x, y, old_fb);
  223. return 0;
  224. }
  225. list_for_each_entry(connector, &mode_config->connector_list, head) {
  226. struct psb_intel_encoder *psb_intel_encoder =
  227. psb_intel_attached_encoder(connector);
  228. if (!connector->encoder
  229. || connector->encoder->crtc != crtc)
  230. continue;
  231. switch (psb_intel_encoder->type) {
  232. case INTEL_OUTPUT_LVDS:
  233. is_lvds = true;
  234. break;
  235. case INTEL_OUTPUT_SDVO:
  236. is_sdvo = true;
  237. break;
  238. case INTEL_OUTPUT_TVOUT:
  239. is_tv = true;
  240. break;
  241. }
  242. }
  243. refclk = 96000;
  244. limit = psb_intel_crtc->clock_funcs->limit(crtc, refclk);
  245. ok = limit->find_pll(limit, crtc, adjusted_mode->clock, refclk,
  246. &clock);
  247. if (!ok) {
  248. DRM_ERROR("Couldn't find PLL settings for mode! target: %d, actual: %d",
  249. adjusted_mode->clock, clock.dot);
  250. return 0;
  251. }
  252. fp = clock.n << 16 | clock.m1 << 8 | clock.m2;
  253. dpll = DPLL_VGA_MODE_DIS;
  254. if (is_lvds) {
  255. dpll |= DPLLB_MODE_LVDS;
  256. dpll |= DPLL_DVO_HIGH_SPEED;
  257. } else
  258. dpll |= DPLLB_MODE_DAC_SERIAL;
  259. if (is_sdvo) {
  260. int sdvo_pixel_multiply =
  261. adjusted_mode->clock / mode->clock;
  262. dpll |= DPLL_DVO_HIGH_SPEED;
  263. dpll |=
  264. (sdvo_pixel_multiply - 1) << SDVO_MULTIPLIER_SHIFT_HIRES;
  265. }
  266. /* compute bitmask from p1 value */
  267. dpll |= (1 << (clock.p1 - 1)) << 16;
  268. switch (clock.p2) {
  269. case 5:
  270. dpll |= DPLL_DAC_SERIAL_P2_CLOCK_DIV_5;
  271. break;
  272. case 7:
  273. dpll |= DPLLB_LVDS_P2_CLOCK_DIV_7;
  274. break;
  275. case 10:
  276. dpll |= DPLL_DAC_SERIAL_P2_CLOCK_DIV_10;
  277. break;
  278. case 14:
  279. dpll |= DPLLB_LVDS_P2_CLOCK_DIV_14;
  280. break;
  281. }
  282. if (is_tv) {
  283. /* XXX: just matching BIOS for now */
  284. /* dpll |= PLL_REF_INPUT_TVCLKINBC; */
  285. dpll |= 3;
  286. }
  287. dpll |= PLL_REF_INPUT_DREFCLK;
  288. /* setup pipeconf */
  289. pipeconf = REG_READ(map->conf);
  290. /* Set up the display plane register */
  291. dspcntr = DISPPLANE_GAMMA_ENABLE;
  292. if (pipe == 0)
  293. dspcntr |= DISPPLANE_SEL_PIPE_A;
  294. else
  295. dspcntr |= DISPPLANE_SEL_PIPE_B;
  296. dspcntr |= DISPLAY_PLANE_ENABLE;
  297. pipeconf |= PIPEACONF_ENABLE;
  298. dpll |= DPLL_VCO_ENABLE;
  299. /* Disable the panel fitter if it was on our pipe */
  300. if (psb_intel_panel_fitter_pipe(dev) == pipe)
  301. REG_WRITE(PFIT_CONTROL, 0);
  302. drm_mode_debug_printmodeline(mode);
  303. if (dpll & DPLL_VCO_ENABLE) {
  304. REG_WRITE(map->fp0, fp);
  305. REG_WRITE(map->dpll, dpll & ~DPLL_VCO_ENABLE);
  306. REG_READ(map->dpll);
  307. udelay(150);
  308. }
  309. /* The LVDS pin pair needs to be on before the DPLLs are enabled.
  310. * This is an exception to the general rule that mode_set doesn't turn
  311. * things on.
  312. */
  313. if (is_lvds) {
  314. u32 lvds = REG_READ(LVDS);
  315. lvds &= ~LVDS_PIPEB_SELECT;
  316. if (pipe == 1)
  317. lvds |= LVDS_PIPEB_SELECT;
  318. lvds |= LVDS_PORT_EN | LVDS_A0A2_CLKA_POWER_UP;
  319. /* Set the B0-B3 data pairs corresponding to
  320. * whether we're going to
  321. * set the DPLLs for dual-channel mode or not.
  322. */
  323. lvds &= ~(LVDS_B0B3_POWER_UP | LVDS_CLKB_POWER_UP);
  324. if (clock.p2 == 7)
  325. lvds |= LVDS_B0B3_POWER_UP | LVDS_CLKB_POWER_UP;
  326. /* It would be nice to set 24 vs 18-bit mode (LVDS_A3_POWER_UP)
  327. * appropriately here, but we need to look more
  328. * thoroughly into how panels behave in the two modes.
  329. */
  330. REG_WRITE(LVDS, lvds);
  331. REG_READ(LVDS);
  332. }
  333. REG_WRITE(map->fp0, fp);
  334. REG_WRITE(map->dpll, dpll);
  335. REG_READ(map->dpll);
  336. /* Wait for the clocks to stabilize. */
  337. udelay(150);
  338. /* write it again -- the BIOS does, after all */
  339. REG_WRITE(map->dpll, dpll);
  340. REG_READ(map->dpll);
  341. /* Wait for the clocks to stabilize. */
  342. udelay(150);
  343. REG_WRITE(map->htotal, (adjusted_mode->crtc_hdisplay - 1) |
  344. ((adjusted_mode->crtc_htotal - 1) << 16));
  345. REG_WRITE(map->hblank, (adjusted_mode->crtc_hblank_start - 1) |
  346. ((adjusted_mode->crtc_hblank_end - 1) << 16));
  347. REG_WRITE(map->hsync, (adjusted_mode->crtc_hsync_start - 1) |
  348. ((adjusted_mode->crtc_hsync_end - 1) << 16));
  349. REG_WRITE(map->vtotal, (adjusted_mode->crtc_vdisplay - 1) |
  350. ((adjusted_mode->crtc_vtotal - 1) << 16));
  351. REG_WRITE(map->vblank, (adjusted_mode->crtc_vblank_start - 1) |
  352. ((adjusted_mode->crtc_vblank_end - 1) << 16));
  353. REG_WRITE(map->vsync, (adjusted_mode->crtc_vsync_start - 1) |
  354. ((adjusted_mode->crtc_vsync_end - 1) << 16));
  355. /* pipesrc and dspsize control the size that is scaled from,
  356. * which should always be the user's requested size.
  357. */
  358. REG_WRITE(map->size,
  359. ((mode->vdisplay - 1) << 16) | (mode->hdisplay - 1));
  360. REG_WRITE(map->pos, 0);
  361. REG_WRITE(map->src,
  362. ((mode->hdisplay - 1) << 16) | (mode->vdisplay - 1));
  363. REG_WRITE(map->conf, pipeconf);
  364. REG_READ(map->conf);
  365. gma_wait_for_vblank(dev);
  366. REG_WRITE(map->cntr, dspcntr);
  367. /* Flush the plane changes */
  368. crtc_funcs->mode_set_base(crtc, x, y, old_fb);
  369. gma_wait_for_vblank(dev);
  370. return 0;
  371. }
  372. /** Loads the palette/gamma unit for the CRTC with the prepared values */
  373. void psb_intel_crtc_load_lut(struct drm_crtc *crtc)
  374. {
  375. struct drm_device *dev = crtc->dev;
  376. struct drm_psb_private *dev_priv = dev->dev_private;
  377. struct psb_intel_crtc *psb_intel_crtc = to_psb_intel_crtc(crtc);
  378. const struct psb_offset *map = &dev_priv->regmap[psb_intel_crtc->pipe];
  379. int palreg = map->palette;
  380. int i;
  381. /* The clocks have to be on to load the palette. */
  382. if (!crtc->enabled)
  383. return;
  384. switch (psb_intel_crtc->pipe) {
  385. case 0:
  386. case 1:
  387. break;
  388. default:
  389. dev_err(dev->dev, "Illegal Pipe Number.\n");
  390. return;
  391. }
  392. if (gma_power_begin(dev, false)) {
  393. for (i = 0; i < 256; i++) {
  394. REG_WRITE(palreg + 4 * i,
  395. ((psb_intel_crtc->lut_r[i] +
  396. psb_intel_crtc->lut_adj[i]) << 16) |
  397. ((psb_intel_crtc->lut_g[i] +
  398. psb_intel_crtc->lut_adj[i]) << 8) |
  399. (psb_intel_crtc->lut_b[i] +
  400. psb_intel_crtc->lut_adj[i]));
  401. }
  402. gma_power_end(dev);
  403. } else {
  404. for (i = 0; i < 256; i++) {
  405. dev_priv->regs.pipe[0].palette[i] =
  406. ((psb_intel_crtc->lut_r[i] +
  407. psb_intel_crtc->lut_adj[i]) << 16) |
  408. ((psb_intel_crtc->lut_g[i] +
  409. psb_intel_crtc->lut_adj[i]) << 8) |
  410. (psb_intel_crtc->lut_b[i] +
  411. psb_intel_crtc->lut_adj[i]);
  412. }
  413. }
  414. }
  415. /**
  416. * Save HW states of giving crtc
  417. */
  418. static void psb_intel_crtc_save(struct drm_crtc *crtc)
  419. {
  420. struct drm_device *dev = crtc->dev;
  421. struct drm_psb_private *dev_priv = dev->dev_private;
  422. struct psb_intel_crtc *psb_intel_crtc = to_psb_intel_crtc(crtc);
  423. struct psb_intel_crtc_state *crtc_state = psb_intel_crtc->crtc_state;
  424. const struct psb_offset *map = &dev_priv->regmap[psb_intel_crtc->pipe];
  425. uint32_t paletteReg;
  426. int i;
  427. if (!crtc_state) {
  428. dev_err(dev->dev, "No CRTC state found\n");
  429. return;
  430. }
  431. crtc_state->saveDSPCNTR = REG_READ(map->cntr);
  432. crtc_state->savePIPECONF = REG_READ(map->conf);
  433. crtc_state->savePIPESRC = REG_READ(map->src);
  434. crtc_state->saveFP0 = REG_READ(map->fp0);
  435. crtc_state->saveFP1 = REG_READ(map->fp1);
  436. crtc_state->saveDPLL = REG_READ(map->dpll);
  437. crtc_state->saveHTOTAL = REG_READ(map->htotal);
  438. crtc_state->saveHBLANK = REG_READ(map->hblank);
  439. crtc_state->saveHSYNC = REG_READ(map->hsync);
  440. crtc_state->saveVTOTAL = REG_READ(map->vtotal);
  441. crtc_state->saveVBLANK = REG_READ(map->vblank);
  442. crtc_state->saveVSYNC = REG_READ(map->vsync);
  443. crtc_state->saveDSPSTRIDE = REG_READ(map->stride);
  444. /*NOTE: DSPSIZE DSPPOS only for psb*/
  445. crtc_state->saveDSPSIZE = REG_READ(map->size);
  446. crtc_state->saveDSPPOS = REG_READ(map->pos);
  447. crtc_state->saveDSPBASE = REG_READ(map->base);
  448. paletteReg = map->palette;
  449. for (i = 0; i < 256; ++i)
  450. crtc_state->savePalette[i] = REG_READ(paletteReg + (i << 2));
  451. }
  452. /**
  453. * Restore HW states of giving crtc
  454. */
  455. static void psb_intel_crtc_restore(struct drm_crtc *crtc)
  456. {
  457. struct drm_device *dev = crtc->dev;
  458. struct drm_psb_private *dev_priv = dev->dev_private;
  459. struct psb_intel_crtc *psb_intel_crtc = to_psb_intel_crtc(crtc);
  460. struct psb_intel_crtc_state *crtc_state = psb_intel_crtc->crtc_state;
  461. const struct psb_offset *map = &dev_priv->regmap[psb_intel_crtc->pipe];
  462. uint32_t paletteReg;
  463. int i;
  464. if (!crtc_state) {
  465. dev_err(dev->dev, "No crtc state\n");
  466. return;
  467. }
  468. if (crtc_state->saveDPLL & DPLL_VCO_ENABLE) {
  469. REG_WRITE(map->dpll,
  470. crtc_state->saveDPLL & ~DPLL_VCO_ENABLE);
  471. REG_READ(map->dpll);
  472. udelay(150);
  473. }
  474. REG_WRITE(map->fp0, crtc_state->saveFP0);
  475. REG_READ(map->fp0);
  476. REG_WRITE(map->fp1, crtc_state->saveFP1);
  477. REG_READ(map->fp1);
  478. REG_WRITE(map->dpll, crtc_state->saveDPLL);
  479. REG_READ(map->dpll);
  480. udelay(150);
  481. REG_WRITE(map->htotal, crtc_state->saveHTOTAL);
  482. REG_WRITE(map->hblank, crtc_state->saveHBLANK);
  483. REG_WRITE(map->hsync, crtc_state->saveHSYNC);
  484. REG_WRITE(map->vtotal, crtc_state->saveVTOTAL);
  485. REG_WRITE(map->vblank, crtc_state->saveVBLANK);
  486. REG_WRITE(map->vsync, crtc_state->saveVSYNC);
  487. REG_WRITE(map->stride, crtc_state->saveDSPSTRIDE);
  488. REG_WRITE(map->size, crtc_state->saveDSPSIZE);
  489. REG_WRITE(map->pos, crtc_state->saveDSPPOS);
  490. REG_WRITE(map->src, crtc_state->savePIPESRC);
  491. REG_WRITE(map->base, crtc_state->saveDSPBASE);
  492. REG_WRITE(map->conf, crtc_state->savePIPECONF);
  493. gma_wait_for_vblank(dev);
  494. REG_WRITE(map->cntr, crtc_state->saveDSPCNTR);
  495. REG_WRITE(map->base, crtc_state->saveDSPBASE);
  496. gma_wait_for_vblank(dev);
  497. paletteReg = map->palette;
  498. for (i = 0; i < 256; ++i)
  499. REG_WRITE(paletteReg + (i << 2), crtc_state->savePalette[i]);
  500. }
  501. static int psb_intel_crtc_cursor_set(struct drm_crtc *crtc,
  502. struct drm_file *file_priv,
  503. uint32_t handle,
  504. uint32_t width, uint32_t height)
  505. {
  506. struct drm_device *dev = crtc->dev;
  507. struct drm_psb_private *dev_priv = dev->dev_private;
  508. struct psb_intel_crtc *psb_intel_crtc = to_psb_intel_crtc(crtc);
  509. int pipe = psb_intel_crtc->pipe;
  510. uint32_t control = (pipe == 0) ? CURACNTR : CURBCNTR;
  511. uint32_t base = (pipe == 0) ? CURABASE : CURBBASE;
  512. uint32_t temp;
  513. size_t addr = 0;
  514. struct gtt_range *gt;
  515. struct gtt_range *cursor_gt = psb_intel_crtc->cursor_gt;
  516. struct drm_gem_object *obj;
  517. void *tmp_dst, *tmp_src;
  518. int ret = 0, i, cursor_pages;
  519. /* if we want to turn of the cursor ignore width and height */
  520. if (!handle) {
  521. /* turn off the cursor */
  522. temp = CURSOR_MODE_DISABLE;
  523. if (gma_power_begin(dev, false)) {
  524. REG_WRITE(control, temp);
  525. REG_WRITE(base, 0);
  526. gma_power_end(dev);
  527. }
  528. /* Unpin the old GEM object */
  529. if (psb_intel_crtc->cursor_obj) {
  530. gt = container_of(psb_intel_crtc->cursor_obj,
  531. struct gtt_range, gem);
  532. psb_gtt_unpin(gt);
  533. drm_gem_object_unreference(psb_intel_crtc->cursor_obj);
  534. psb_intel_crtc->cursor_obj = NULL;
  535. }
  536. return 0;
  537. }
  538. /* Currently we only support 64x64 cursors */
  539. if (width != 64 || height != 64) {
  540. dev_dbg(dev->dev, "we currently only support 64x64 cursors\n");
  541. return -EINVAL;
  542. }
  543. obj = drm_gem_object_lookup(dev, file_priv, handle);
  544. if (!obj)
  545. return -ENOENT;
  546. if (obj->size < width * height * 4) {
  547. dev_dbg(dev->dev, "buffer is to small\n");
  548. ret = -ENOMEM;
  549. goto unref_cursor;
  550. }
  551. gt = container_of(obj, struct gtt_range, gem);
  552. /* Pin the memory into the GTT */
  553. ret = psb_gtt_pin(gt);
  554. if (ret) {
  555. dev_err(dev->dev, "Can not pin down handle 0x%x\n", handle);
  556. goto unref_cursor;
  557. }
  558. if (dev_priv->ops->cursor_needs_phys) {
  559. if (cursor_gt == NULL) {
  560. dev_err(dev->dev, "No hardware cursor mem available");
  561. ret = -ENOMEM;
  562. goto unref_cursor;
  563. }
  564. /* Prevent overflow */
  565. if (gt->npage > 4)
  566. cursor_pages = 4;
  567. else
  568. cursor_pages = gt->npage;
  569. /* Copy the cursor to cursor mem */
  570. tmp_dst = dev_priv->vram_addr + cursor_gt->offset;
  571. for (i = 0; i < cursor_pages; i++) {
  572. tmp_src = kmap(gt->pages[i]);
  573. memcpy(tmp_dst, tmp_src, PAGE_SIZE);
  574. kunmap(gt->pages[i]);
  575. tmp_dst += PAGE_SIZE;
  576. }
  577. addr = psb_intel_crtc->cursor_addr;
  578. } else {
  579. addr = gt->offset; /* Or resource.start ??? */
  580. psb_intel_crtc->cursor_addr = addr;
  581. }
  582. temp = 0;
  583. /* set the pipe for the cursor */
  584. temp |= (pipe << 28);
  585. temp |= CURSOR_MODE_64_ARGB_AX | MCURSOR_GAMMA_ENABLE;
  586. if (gma_power_begin(dev, false)) {
  587. REG_WRITE(control, temp);
  588. REG_WRITE(base, addr);
  589. gma_power_end(dev);
  590. }
  591. /* unpin the old bo */
  592. if (psb_intel_crtc->cursor_obj) {
  593. gt = container_of(psb_intel_crtc->cursor_obj,
  594. struct gtt_range, gem);
  595. psb_gtt_unpin(gt);
  596. drm_gem_object_unreference(psb_intel_crtc->cursor_obj);
  597. }
  598. psb_intel_crtc->cursor_obj = obj;
  599. return ret;
  600. unref_cursor:
  601. drm_gem_object_unreference(obj);
  602. return ret;
  603. }
  604. static int psb_intel_crtc_cursor_move(struct drm_crtc *crtc, int x, int y)
  605. {
  606. struct drm_device *dev = crtc->dev;
  607. struct psb_intel_crtc *psb_intel_crtc = to_psb_intel_crtc(crtc);
  608. int pipe = psb_intel_crtc->pipe;
  609. uint32_t temp = 0;
  610. uint32_t addr;
  611. if (x < 0) {
  612. temp |= (CURSOR_POS_SIGN << CURSOR_X_SHIFT);
  613. x = -x;
  614. }
  615. if (y < 0) {
  616. temp |= (CURSOR_POS_SIGN << CURSOR_Y_SHIFT);
  617. y = -y;
  618. }
  619. temp |= ((x & CURSOR_POS_MASK) << CURSOR_X_SHIFT);
  620. temp |= ((y & CURSOR_POS_MASK) << CURSOR_Y_SHIFT);
  621. addr = psb_intel_crtc->cursor_addr;
  622. if (gma_power_begin(dev, false)) {
  623. REG_WRITE((pipe == 0) ? CURAPOS : CURBPOS, temp);
  624. REG_WRITE((pipe == 0) ? CURABASE : CURBBASE, addr);
  625. gma_power_end(dev);
  626. }
  627. return 0;
  628. }
  629. static void psb_intel_crtc_gamma_set(struct drm_crtc *crtc, u16 *red,
  630. u16 *green, u16 *blue, uint32_t type, uint32_t size)
  631. {
  632. struct psb_intel_crtc *psb_intel_crtc = to_psb_intel_crtc(crtc);
  633. int i;
  634. if (size != 256)
  635. return;
  636. for (i = 0; i < 256; i++) {
  637. psb_intel_crtc->lut_r[i] = red[i] >> 8;
  638. psb_intel_crtc->lut_g[i] = green[i] >> 8;
  639. psb_intel_crtc->lut_b[i] = blue[i] >> 8;
  640. }
  641. psb_intel_crtc_load_lut(crtc);
  642. }
  643. static int psb_crtc_set_config(struct drm_mode_set *set)
  644. {
  645. int ret;
  646. struct drm_device *dev = set->crtc->dev;
  647. struct drm_psb_private *dev_priv = dev->dev_private;
  648. if (!dev_priv->rpm_enabled)
  649. return drm_crtc_helper_set_config(set);
  650. pm_runtime_forbid(&dev->pdev->dev);
  651. ret = drm_crtc_helper_set_config(set);
  652. pm_runtime_allow(&dev->pdev->dev);
  653. return ret;
  654. }
  655. /* Returns the clock of the currently programmed mode of the given pipe. */
  656. static int psb_intel_crtc_clock_get(struct drm_device *dev,
  657. struct drm_crtc *crtc)
  658. {
  659. struct psb_intel_crtc *psb_intel_crtc = to_psb_intel_crtc(crtc);
  660. struct drm_psb_private *dev_priv = dev->dev_private;
  661. int pipe = psb_intel_crtc->pipe;
  662. const struct psb_offset *map = &dev_priv->regmap[pipe];
  663. u32 dpll;
  664. u32 fp;
  665. struct gma_clock_t clock;
  666. bool is_lvds;
  667. struct psb_pipe *p = &dev_priv->regs.pipe[pipe];
  668. if (gma_power_begin(dev, false)) {
  669. dpll = REG_READ(map->dpll);
  670. if ((dpll & DISPLAY_RATE_SELECT_FPA1) == 0)
  671. fp = REG_READ(map->fp0);
  672. else
  673. fp = REG_READ(map->fp1);
  674. is_lvds = (pipe == 1) && (REG_READ(LVDS) & LVDS_PORT_EN);
  675. gma_power_end(dev);
  676. } else {
  677. dpll = p->dpll;
  678. if ((dpll & DISPLAY_RATE_SELECT_FPA1) == 0)
  679. fp = p->fp0;
  680. else
  681. fp = p->fp1;
  682. is_lvds = (pipe == 1) && (dev_priv->regs.psb.saveLVDS &
  683. LVDS_PORT_EN);
  684. }
  685. clock.m1 = (fp & FP_M1_DIV_MASK) >> FP_M1_DIV_SHIFT;
  686. clock.m2 = (fp & FP_M2_DIV_MASK) >> FP_M2_DIV_SHIFT;
  687. clock.n = (fp & FP_N_DIV_MASK) >> FP_N_DIV_SHIFT;
  688. if (is_lvds) {
  689. clock.p1 =
  690. ffs((dpll &
  691. DPLL_FPA01_P1_POST_DIV_MASK_I830_LVDS) >>
  692. DPLL_FPA01_P1_POST_DIV_SHIFT);
  693. clock.p2 = 14;
  694. if ((dpll & PLL_REF_INPUT_MASK) ==
  695. PLLB_REF_INPUT_SPREADSPECTRUMIN) {
  696. /* XXX: might not be 66MHz */
  697. psb_intel_clock(66000, &clock);
  698. } else
  699. psb_intel_clock(48000, &clock);
  700. } else {
  701. if (dpll & PLL_P1_DIVIDE_BY_TWO)
  702. clock.p1 = 2;
  703. else {
  704. clock.p1 =
  705. ((dpll &
  706. DPLL_FPA01_P1_POST_DIV_MASK_I830) >>
  707. DPLL_FPA01_P1_POST_DIV_SHIFT) + 2;
  708. }
  709. if (dpll & PLL_P2_DIVIDE_BY_4)
  710. clock.p2 = 4;
  711. else
  712. clock.p2 = 2;
  713. psb_intel_clock(48000, &clock);
  714. }
  715. /* XXX: It would be nice to validate the clocks, but we can't reuse
  716. * i830PllIsValid() because it relies on the xf86_config connector
  717. * configuration being accurate, which it isn't necessarily.
  718. */
  719. return clock.dot;
  720. }
  721. /** Returns the currently programmed mode of the given pipe. */
  722. struct drm_display_mode *psb_intel_crtc_mode_get(struct drm_device *dev,
  723. struct drm_crtc *crtc)
  724. {
  725. struct psb_intel_crtc *psb_intel_crtc = to_psb_intel_crtc(crtc);
  726. int pipe = psb_intel_crtc->pipe;
  727. struct drm_display_mode *mode;
  728. int htot;
  729. int hsync;
  730. int vtot;
  731. int vsync;
  732. struct drm_psb_private *dev_priv = dev->dev_private;
  733. struct psb_pipe *p = &dev_priv->regs.pipe[pipe];
  734. const struct psb_offset *map = &dev_priv->regmap[pipe];
  735. if (gma_power_begin(dev, false)) {
  736. htot = REG_READ(map->htotal);
  737. hsync = REG_READ(map->hsync);
  738. vtot = REG_READ(map->vtotal);
  739. vsync = REG_READ(map->vsync);
  740. gma_power_end(dev);
  741. } else {
  742. htot = p->htotal;
  743. hsync = p->hsync;
  744. vtot = p->vtotal;
  745. vsync = p->vsync;
  746. }
  747. mode = kzalloc(sizeof(*mode), GFP_KERNEL);
  748. if (!mode)
  749. return NULL;
  750. mode->clock = psb_intel_crtc_clock_get(dev, crtc);
  751. mode->hdisplay = (htot & 0xffff) + 1;
  752. mode->htotal = ((htot & 0xffff0000) >> 16) + 1;
  753. mode->hsync_start = (hsync & 0xffff) + 1;
  754. mode->hsync_end = ((hsync & 0xffff0000) >> 16) + 1;
  755. mode->vdisplay = (vtot & 0xffff) + 1;
  756. mode->vtotal = ((vtot & 0xffff0000) >> 16) + 1;
  757. mode->vsync_start = (vsync & 0xffff) + 1;
  758. mode->vsync_end = ((vsync & 0xffff0000) >> 16) + 1;
  759. drm_mode_set_name(mode);
  760. drm_mode_set_crtcinfo(mode, 0);
  761. return mode;
  762. }
  763. static void psb_intel_crtc_destroy(struct drm_crtc *crtc)
  764. {
  765. struct psb_intel_crtc *psb_intel_crtc = to_psb_intel_crtc(crtc);
  766. struct gtt_range *gt;
  767. /* Unpin the old GEM object */
  768. if (psb_intel_crtc->cursor_obj) {
  769. gt = container_of(psb_intel_crtc->cursor_obj,
  770. struct gtt_range, gem);
  771. psb_gtt_unpin(gt);
  772. drm_gem_object_unreference(psb_intel_crtc->cursor_obj);
  773. psb_intel_crtc->cursor_obj = NULL;
  774. }
  775. if (psb_intel_crtc->cursor_gt != NULL)
  776. psb_gtt_free_range(crtc->dev, psb_intel_crtc->cursor_gt);
  777. kfree(psb_intel_crtc->crtc_state);
  778. drm_crtc_cleanup(crtc);
  779. kfree(psb_intel_crtc);
  780. }
  781. const struct drm_crtc_helper_funcs psb_intel_helper_funcs = {
  782. .dpms = psb_intel_crtc_dpms,
  783. .mode_fixup = gma_crtc_mode_fixup,
  784. .mode_set = psb_intel_crtc_mode_set,
  785. .mode_set_base = gma_pipe_set_base,
  786. .prepare = gma_crtc_prepare,
  787. .commit = gma_crtc_commit,
  788. .disable = gma_crtc_disable,
  789. };
  790. const struct drm_crtc_funcs psb_intel_crtc_funcs = {
  791. .save = psb_intel_crtc_save,
  792. .restore = psb_intel_crtc_restore,
  793. .cursor_set = psb_intel_crtc_cursor_set,
  794. .cursor_move = psb_intel_crtc_cursor_move,
  795. .gamma_set = psb_intel_crtc_gamma_set,
  796. .set_config = psb_crtc_set_config,
  797. .destroy = psb_intel_crtc_destroy,
  798. };
  799. const struct gma_clock_funcs psb_clock_funcs = {
  800. .clock = psb_intel_clock,
  801. .limit = psb_intel_limit,
  802. .pll_is_valid = gma_pll_is_valid,
  803. };
  804. /*
  805. * Set the default value of cursor control and base register
  806. * to zero. This is a workaround for h/w defect on Oaktrail
  807. */
  808. static void psb_intel_cursor_init(struct drm_device *dev,
  809. struct psb_intel_crtc *psb_intel_crtc)
  810. {
  811. struct drm_psb_private *dev_priv = dev->dev_private;
  812. u32 control[3] = { CURACNTR, CURBCNTR, CURCCNTR };
  813. u32 base[3] = { CURABASE, CURBBASE, CURCBASE };
  814. struct gtt_range *cursor_gt;
  815. if (dev_priv->ops->cursor_needs_phys) {
  816. /* Allocate 4 pages of stolen mem for a hardware cursor. That
  817. * is enough for the 64 x 64 ARGB cursors we support.
  818. */
  819. cursor_gt = psb_gtt_alloc_range(dev, 4 * PAGE_SIZE, "cursor", 1);
  820. if (!cursor_gt) {
  821. psb_intel_crtc->cursor_gt = NULL;
  822. goto out;
  823. }
  824. psb_intel_crtc->cursor_gt = cursor_gt;
  825. psb_intel_crtc->cursor_addr = dev_priv->stolen_base +
  826. cursor_gt->offset;
  827. } else {
  828. psb_intel_crtc->cursor_gt = NULL;
  829. }
  830. out:
  831. REG_WRITE(control[psb_intel_crtc->pipe], 0);
  832. REG_WRITE(base[psb_intel_crtc->pipe], 0);
  833. }
  834. void psb_intel_crtc_init(struct drm_device *dev, int pipe,
  835. struct psb_intel_mode_device *mode_dev)
  836. {
  837. struct drm_psb_private *dev_priv = dev->dev_private;
  838. struct psb_intel_crtc *psb_intel_crtc;
  839. int i;
  840. uint16_t *r_base, *g_base, *b_base;
  841. /* We allocate a extra array of drm_connector pointers
  842. * for fbdev after the crtc */
  843. psb_intel_crtc =
  844. kzalloc(sizeof(struct psb_intel_crtc) +
  845. (INTELFB_CONN_LIMIT * sizeof(struct drm_connector *)),
  846. GFP_KERNEL);
  847. if (psb_intel_crtc == NULL)
  848. return;
  849. psb_intel_crtc->crtc_state =
  850. kzalloc(sizeof(struct psb_intel_crtc_state), GFP_KERNEL);
  851. if (!psb_intel_crtc->crtc_state) {
  852. dev_err(dev->dev, "Crtc state error: No memory\n");
  853. kfree(psb_intel_crtc);
  854. return;
  855. }
  856. /* Set the CRTC operations from the chip specific data */
  857. drm_crtc_init(dev, &psb_intel_crtc->base, dev_priv->ops->crtc_funcs);
  858. /* Set the CRTC clock functions from chip specific data */
  859. psb_intel_crtc->clock_funcs = dev_priv->ops->clock_funcs;
  860. drm_mode_crtc_set_gamma_size(&psb_intel_crtc->base, 256);
  861. psb_intel_crtc->pipe = pipe;
  862. psb_intel_crtc->plane = pipe;
  863. r_base = psb_intel_crtc->base.gamma_store;
  864. g_base = r_base + 256;
  865. b_base = g_base + 256;
  866. for (i = 0; i < 256; i++) {
  867. psb_intel_crtc->lut_r[i] = i;
  868. psb_intel_crtc->lut_g[i] = i;
  869. psb_intel_crtc->lut_b[i] = i;
  870. r_base[i] = i << 8;
  871. g_base[i] = i << 8;
  872. b_base[i] = i << 8;
  873. psb_intel_crtc->lut_adj[i] = 0;
  874. }
  875. psb_intel_crtc->mode_dev = mode_dev;
  876. psb_intel_crtc->cursor_addr = 0;
  877. drm_crtc_helper_add(&psb_intel_crtc->base,
  878. dev_priv->ops->crtc_helper);
  879. /* Setup the array of drm_connector pointer array */
  880. psb_intel_crtc->mode_set.crtc = &psb_intel_crtc->base;
  881. BUG_ON(pipe >= ARRAY_SIZE(dev_priv->plane_to_crtc_mapping) ||
  882. dev_priv->plane_to_crtc_mapping[psb_intel_crtc->plane] != NULL);
  883. dev_priv->plane_to_crtc_mapping[psb_intel_crtc->plane] =
  884. &psb_intel_crtc->base;
  885. dev_priv->pipe_to_crtc_mapping[psb_intel_crtc->pipe] =
  886. &psb_intel_crtc->base;
  887. psb_intel_crtc->mode_set.connectors =
  888. (struct drm_connector **) (psb_intel_crtc + 1);
  889. psb_intel_crtc->mode_set.num_connectors = 0;
  890. psb_intel_cursor_init(dev, psb_intel_crtc);
  891. /* Set to true so that the pipe is forced off on initial config. */
  892. psb_intel_crtc->active = true;
  893. }
  894. int psb_intel_get_pipe_from_crtc_id(struct drm_device *dev, void *data,
  895. struct drm_file *file_priv)
  896. {
  897. struct drm_psb_private *dev_priv = dev->dev_private;
  898. struct drm_psb_get_pipe_from_crtc_id_arg *pipe_from_crtc_id = data;
  899. struct drm_mode_object *drmmode_obj;
  900. struct psb_intel_crtc *crtc;
  901. if (!dev_priv) {
  902. dev_err(dev->dev, "called with no initialization\n");
  903. return -EINVAL;
  904. }
  905. drmmode_obj = drm_mode_object_find(dev, pipe_from_crtc_id->crtc_id,
  906. DRM_MODE_OBJECT_CRTC);
  907. if (!drmmode_obj) {
  908. dev_err(dev->dev, "no such CRTC id\n");
  909. return -EINVAL;
  910. }
  911. crtc = to_psb_intel_crtc(obj_to_crtc(drmmode_obj));
  912. pipe_from_crtc_id->pipe = crtc->pipe;
  913. return 0;
  914. }
  915. struct drm_crtc *psb_intel_get_crtc_from_pipe(struct drm_device *dev, int pipe)
  916. {
  917. struct drm_crtc *crtc = NULL;
  918. list_for_each_entry(crtc, &dev->mode_config.crtc_list, head) {
  919. struct psb_intel_crtc *psb_intel_crtc = to_psb_intel_crtc(crtc);
  920. if (psb_intel_crtc->pipe == pipe)
  921. break;
  922. }
  923. return crtc;
  924. }
  925. int psb_intel_connector_clones(struct drm_device *dev, int type_mask)
  926. {
  927. int index_mask = 0;
  928. struct drm_connector *connector;
  929. int entry = 0;
  930. list_for_each_entry(connector, &dev->mode_config.connector_list,
  931. head) {
  932. struct psb_intel_encoder *psb_intel_encoder =
  933. psb_intel_attached_encoder(connector);
  934. if (type_mask & (1 << psb_intel_encoder->type))
  935. index_mask |= (1 << entry);
  936. entry++;
  937. }
  938. return index_mask;
  939. }
  940. /* current intel driver doesn't take advantage of encoders
  941. always give back the encoder for the connector
  942. */
  943. struct drm_encoder *psb_intel_best_encoder(struct drm_connector *connector)
  944. {
  945. struct psb_intel_encoder *psb_intel_encoder =
  946. psb_intel_attached_encoder(connector);
  947. return &psb_intel_encoder->base;
  948. }
  949. void psb_intel_connector_attach_encoder(struct psb_intel_connector *connector,
  950. struct psb_intel_encoder *encoder)
  951. {
  952. connector->encoder = encoder;
  953. drm_mode_connector_attach_encoder(&connector->base,
  954. &encoder->base);
  955. }