oaktrail_crtc.c 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586
  1. /*
  2. * Copyright © 2009 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. #include <linux/i2c.h>
  18. #include <linux/pm_runtime.h>
  19. #include <drm/drmP.h>
  20. #include "framebuffer.h"
  21. #include "psb_drv.h"
  22. #include "psb_intel_drv.h"
  23. #include "psb_intel_reg.h"
  24. #include "psb_intel_display.h"
  25. #include "power.h"
  26. struct psb_intel_range_t {
  27. int min, max;
  28. };
  29. struct oaktrail_limit_t {
  30. struct psb_intel_range_t dot, m, p1;
  31. };
  32. struct oaktrail_clock_t {
  33. /* derived values */
  34. int dot;
  35. int m;
  36. int p1;
  37. };
  38. #define MRST_LIMIT_LVDS_100L 0
  39. #define MRST_LIMIT_LVDS_83 1
  40. #define MRST_LIMIT_LVDS_100 2
  41. #define MRST_DOT_MIN 19750
  42. #define MRST_DOT_MAX 120000
  43. #define MRST_M_MIN_100L 20
  44. #define MRST_M_MIN_100 10
  45. #define MRST_M_MIN_83 12
  46. #define MRST_M_MAX_100L 34
  47. #define MRST_M_MAX_100 17
  48. #define MRST_M_MAX_83 20
  49. #define MRST_P1_MIN 2
  50. #define MRST_P1_MAX_0 7
  51. #define MRST_P1_MAX_1 8
  52. static const struct oaktrail_limit_t oaktrail_limits[] = {
  53. { /* MRST_LIMIT_LVDS_100L */
  54. .dot = {.min = MRST_DOT_MIN, .max = MRST_DOT_MAX},
  55. .m = {.min = MRST_M_MIN_100L, .max = MRST_M_MAX_100L},
  56. .p1 = {.min = MRST_P1_MIN, .max = MRST_P1_MAX_1},
  57. },
  58. { /* MRST_LIMIT_LVDS_83L */
  59. .dot = {.min = MRST_DOT_MIN, .max = MRST_DOT_MAX},
  60. .m = {.min = MRST_M_MIN_83, .max = MRST_M_MAX_83},
  61. .p1 = {.min = MRST_P1_MIN, .max = MRST_P1_MAX_0},
  62. },
  63. { /* MRST_LIMIT_LVDS_100 */
  64. .dot = {.min = MRST_DOT_MIN, .max = MRST_DOT_MAX},
  65. .m = {.min = MRST_M_MIN_100, .max = MRST_M_MAX_100},
  66. .p1 = {.min = MRST_P1_MIN, .max = MRST_P1_MAX_1},
  67. },
  68. };
  69. #define MRST_M_MIN 10
  70. static const u32 oaktrail_m_converts[] = {
  71. 0x2B, 0x15, 0x2A, 0x35, 0x1A, 0x0D, 0x26, 0x33, 0x19, 0x2C,
  72. 0x36, 0x3B, 0x1D, 0x2E, 0x37, 0x1B, 0x2D, 0x16, 0x0B, 0x25,
  73. 0x12, 0x09, 0x24, 0x32, 0x39, 0x1c,
  74. };
  75. static const struct oaktrail_limit_t *oaktrail_limit(struct drm_crtc *crtc)
  76. {
  77. const struct oaktrail_limit_t *limit = NULL;
  78. struct drm_device *dev = crtc->dev;
  79. struct drm_psb_private *dev_priv = dev->dev_private;
  80. if (psb_intel_pipe_has_type(crtc, INTEL_OUTPUT_LVDS)
  81. || psb_intel_pipe_has_type(crtc, INTEL_OUTPUT_MIPI)) {
  82. switch (dev_priv->core_freq) {
  83. case 100:
  84. limit = &oaktrail_limits[MRST_LIMIT_LVDS_100L];
  85. break;
  86. case 166:
  87. limit = &oaktrail_limits[MRST_LIMIT_LVDS_83];
  88. break;
  89. case 200:
  90. limit = &oaktrail_limits[MRST_LIMIT_LVDS_100];
  91. break;
  92. }
  93. } else {
  94. limit = NULL;
  95. dev_err(dev->dev, "oaktrail_limit Wrong display type.\n");
  96. }
  97. return limit;
  98. }
  99. /** Derive the pixel clock for the given refclk and divisors for 8xx chips. */
  100. static void oaktrail_clock(int refclk, struct oaktrail_clock_t *clock)
  101. {
  102. clock->dot = (refclk * clock->m) / (14 * clock->p1);
  103. }
  104. static void mrstPrintPll(char *prefix, struct oaktrail_clock_t *clock)
  105. {
  106. pr_debug("%s: dotclock = %d, m = %d, p1 = %d.\n",
  107. prefix, clock->dot, clock->m, clock->p1);
  108. }
  109. /**
  110. * Returns a set of divisors for the desired target clock with the given refclk,
  111. * or FALSE. Divisor values are the actual divisors for
  112. */
  113. static bool
  114. mrstFindBestPLL(struct drm_crtc *crtc, int target, int refclk,
  115. struct oaktrail_clock_t *best_clock)
  116. {
  117. struct oaktrail_clock_t clock;
  118. const struct oaktrail_limit_t *limit = oaktrail_limit(crtc);
  119. int err = target;
  120. memset(best_clock, 0, sizeof(*best_clock));
  121. for (clock.m = limit->m.min; clock.m <= limit->m.max; clock.m++) {
  122. for (clock.p1 = limit->p1.min; clock.p1 <= limit->p1.max;
  123. clock.p1++) {
  124. int this_err;
  125. oaktrail_clock(refclk, &clock);
  126. this_err = abs(clock.dot - target);
  127. if (this_err < err) {
  128. *best_clock = clock;
  129. err = this_err;
  130. }
  131. }
  132. }
  133. dev_dbg(crtc->dev->dev, "mrstFindBestPLL err = %d.\n", err);
  134. return err != target;
  135. }
  136. /**
  137. * Sets the power management mode of the pipe and plane.
  138. *
  139. * This code should probably grow support for turning the cursor off and back
  140. * on appropriately at the same time as we're turning the pipe off/on.
  141. */
  142. static void oaktrail_crtc_dpms(struct drm_crtc *crtc, int mode)
  143. {
  144. struct drm_device *dev = crtc->dev;
  145. struct drm_psb_private *dev_priv = dev->dev_private;
  146. struct psb_intel_crtc *psb_intel_crtc = to_psb_intel_crtc(crtc);
  147. int pipe = psb_intel_crtc->pipe;
  148. const struct psb_offset *map = &dev_priv->regmap[pipe];
  149. u32 temp;
  150. if (pipe == 1) {
  151. oaktrail_crtc_hdmi_dpms(crtc, mode);
  152. return;
  153. }
  154. if (!gma_power_begin(dev, true))
  155. return;
  156. /* XXX: When our outputs are all unaware of DPMS modes other than off
  157. * and on, we should map those modes to DRM_MODE_DPMS_OFF in the CRTC.
  158. */
  159. switch (mode) {
  160. case DRM_MODE_DPMS_ON:
  161. case DRM_MODE_DPMS_STANDBY:
  162. case DRM_MODE_DPMS_SUSPEND:
  163. /* Enable the DPLL */
  164. temp = REG_READ(map->dpll);
  165. if ((temp & DPLL_VCO_ENABLE) == 0) {
  166. REG_WRITE(map->dpll, temp);
  167. REG_READ(map->dpll);
  168. /* Wait for the clocks to stabilize. */
  169. udelay(150);
  170. REG_WRITE(map->dpll, temp | DPLL_VCO_ENABLE);
  171. REG_READ(map->dpll);
  172. /* Wait for the clocks to stabilize. */
  173. udelay(150);
  174. REG_WRITE(map->dpll, temp | DPLL_VCO_ENABLE);
  175. REG_READ(map->dpll);
  176. /* Wait for the clocks to stabilize. */
  177. udelay(150);
  178. }
  179. /* Enable the pipe */
  180. temp = REG_READ(map->conf);
  181. if ((temp & PIPEACONF_ENABLE) == 0)
  182. REG_WRITE(map->conf, temp | PIPEACONF_ENABLE);
  183. /* Enable the plane */
  184. temp = REG_READ(map->cntr);
  185. if ((temp & DISPLAY_PLANE_ENABLE) == 0) {
  186. REG_WRITE(map->cntr,
  187. temp | DISPLAY_PLANE_ENABLE);
  188. /* Flush the plane changes */
  189. REG_WRITE(map->base, REG_READ(map->base));
  190. }
  191. psb_intel_crtc_load_lut(crtc);
  192. /* Give the overlay scaler a chance to enable
  193. if it's on this pipe */
  194. /* psb_intel_crtc_dpms_video(crtc, true); TODO */
  195. break;
  196. case DRM_MODE_DPMS_OFF:
  197. /* Give the overlay scaler a chance to disable
  198. * if it's on this pipe */
  199. /* psb_intel_crtc_dpms_video(crtc, FALSE); TODO */
  200. /* Disable the VGA plane that we never use */
  201. REG_WRITE(VGACNTRL, VGA_DISP_DISABLE);
  202. /* Disable display plane */
  203. temp = REG_READ(map->cntr);
  204. if ((temp & DISPLAY_PLANE_ENABLE) != 0) {
  205. REG_WRITE(map->cntr,
  206. temp & ~DISPLAY_PLANE_ENABLE);
  207. /* Flush the plane changes */
  208. REG_WRITE(map->base, REG_READ(map->base));
  209. REG_READ(map->base);
  210. }
  211. /* Next, disable display pipes */
  212. temp = REG_READ(map->conf);
  213. if ((temp & PIPEACONF_ENABLE) != 0) {
  214. REG_WRITE(map->conf, temp & ~PIPEACONF_ENABLE);
  215. REG_READ(map->conf);
  216. }
  217. /* Wait for for the pipe disable to take effect. */
  218. psb_intel_wait_for_vblank(dev);
  219. temp = REG_READ(map->dpll);
  220. if ((temp & DPLL_VCO_ENABLE) != 0) {
  221. REG_WRITE(map->dpll, temp & ~DPLL_VCO_ENABLE);
  222. REG_READ(map->dpll);
  223. }
  224. /* Wait for the clocks to turn off. */
  225. udelay(150);
  226. break;
  227. }
  228. /*Set FIFO Watermarks*/
  229. REG_WRITE(DSPARB, 0x3FFF);
  230. REG_WRITE(DSPFW1, 0x3F88080A);
  231. REG_WRITE(DSPFW2, 0x0b060808);
  232. REG_WRITE(DSPFW3, 0x0);
  233. REG_WRITE(DSPFW4, 0x08030404);
  234. REG_WRITE(DSPFW5, 0x04040404);
  235. REG_WRITE(DSPFW6, 0x78);
  236. REG_WRITE(0x70400, REG_READ(0x70400) | 0x4000);
  237. /* Must write Bit 14 of the Chicken Bit Register */
  238. gma_power_end(dev);
  239. }
  240. /**
  241. * Return the pipe currently connected to the panel fitter,
  242. * or -1 if the panel fitter is not present or not in use
  243. */
  244. static int oaktrail_panel_fitter_pipe(struct drm_device *dev)
  245. {
  246. u32 pfit_control;
  247. pfit_control = REG_READ(PFIT_CONTROL);
  248. /* See if the panel fitter is in use */
  249. if ((pfit_control & PFIT_ENABLE) == 0)
  250. return -1;
  251. return (pfit_control >> 29) & 3;
  252. }
  253. static int oaktrail_crtc_mode_set(struct drm_crtc *crtc,
  254. struct drm_display_mode *mode,
  255. struct drm_display_mode *adjusted_mode,
  256. int x, int y,
  257. struct drm_framebuffer *old_fb)
  258. {
  259. struct drm_device *dev = crtc->dev;
  260. struct psb_intel_crtc *psb_intel_crtc = to_psb_intel_crtc(crtc);
  261. struct drm_psb_private *dev_priv = dev->dev_private;
  262. int pipe = psb_intel_crtc->pipe;
  263. const struct psb_offset *map = &dev_priv->regmap[pipe];
  264. int refclk = 0;
  265. struct oaktrail_clock_t clock;
  266. u32 dpll = 0, fp = 0, dspcntr, pipeconf;
  267. bool ok, is_sdvo = false;
  268. bool is_lvds = false;
  269. bool is_mipi = false;
  270. struct drm_mode_config *mode_config = &dev->mode_config;
  271. struct psb_intel_encoder *psb_intel_encoder = NULL;
  272. uint64_t scalingType = DRM_MODE_SCALE_FULLSCREEN;
  273. struct drm_connector *connector;
  274. if (pipe == 1)
  275. return oaktrail_crtc_hdmi_mode_set(crtc, mode, adjusted_mode, x, y, old_fb);
  276. if (!gma_power_begin(dev, true))
  277. return 0;
  278. memcpy(&psb_intel_crtc->saved_mode,
  279. mode,
  280. sizeof(struct drm_display_mode));
  281. memcpy(&psb_intel_crtc->saved_adjusted_mode,
  282. adjusted_mode,
  283. sizeof(struct drm_display_mode));
  284. list_for_each_entry(connector, &mode_config->connector_list, head) {
  285. if (!connector->encoder || connector->encoder->crtc != crtc)
  286. continue;
  287. psb_intel_encoder = psb_intel_attached_encoder(connector);
  288. switch (psb_intel_encoder->type) {
  289. case INTEL_OUTPUT_LVDS:
  290. is_lvds = true;
  291. break;
  292. case INTEL_OUTPUT_SDVO:
  293. is_sdvo = true;
  294. break;
  295. case INTEL_OUTPUT_MIPI:
  296. is_mipi = true;
  297. break;
  298. }
  299. }
  300. /* Disable the VGA plane that we never use */
  301. REG_WRITE(VGACNTRL, VGA_DISP_DISABLE);
  302. /* Disable the panel fitter if it was on our pipe */
  303. if (oaktrail_panel_fitter_pipe(dev) == pipe)
  304. REG_WRITE(PFIT_CONTROL, 0);
  305. REG_WRITE(map->src,
  306. ((mode->crtc_hdisplay - 1) << 16) |
  307. (mode->crtc_vdisplay - 1));
  308. if (psb_intel_encoder)
  309. drm_object_property_get_value(&connector->base,
  310. dev->mode_config.scaling_mode_property, &scalingType);
  311. if (scalingType == DRM_MODE_SCALE_NO_SCALE) {
  312. /* Moorestown doesn't have register support for centering so
  313. * we need to mess with the h/vblank and h/vsync start and
  314. * ends to get centering */
  315. int offsetX = 0, offsetY = 0;
  316. offsetX = (adjusted_mode->crtc_hdisplay -
  317. mode->crtc_hdisplay) / 2;
  318. offsetY = (adjusted_mode->crtc_vdisplay -
  319. mode->crtc_vdisplay) / 2;
  320. REG_WRITE(map->htotal, (mode->crtc_hdisplay - 1) |
  321. ((adjusted_mode->crtc_htotal - 1) << 16));
  322. REG_WRITE(map->vtotal, (mode->crtc_vdisplay - 1) |
  323. ((adjusted_mode->crtc_vtotal - 1) << 16));
  324. REG_WRITE(map->hblank,
  325. (adjusted_mode->crtc_hblank_start - offsetX - 1) |
  326. ((adjusted_mode->crtc_hblank_end - offsetX - 1) << 16));
  327. REG_WRITE(map->hsync,
  328. (adjusted_mode->crtc_hsync_start - offsetX - 1) |
  329. ((adjusted_mode->crtc_hsync_end - offsetX - 1) << 16));
  330. REG_WRITE(map->vblank,
  331. (adjusted_mode->crtc_vblank_start - offsetY - 1) |
  332. ((adjusted_mode->crtc_vblank_end - offsetY - 1) << 16));
  333. REG_WRITE(map->vsync,
  334. (adjusted_mode->crtc_vsync_start - offsetY - 1) |
  335. ((adjusted_mode->crtc_vsync_end - offsetY - 1) << 16));
  336. } else {
  337. REG_WRITE(map->htotal, (adjusted_mode->crtc_hdisplay - 1) |
  338. ((adjusted_mode->crtc_htotal - 1) << 16));
  339. REG_WRITE(map->vtotal, (adjusted_mode->crtc_vdisplay - 1) |
  340. ((adjusted_mode->crtc_vtotal - 1) << 16));
  341. REG_WRITE(map->hblank, (adjusted_mode->crtc_hblank_start - 1) |
  342. ((adjusted_mode->crtc_hblank_end - 1) << 16));
  343. REG_WRITE(map->hsync, (adjusted_mode->crtc_hsync_start - 1) |
  344. ((adjusted_mode->crtc_hsync_end - 1) << 16));
  345. REG_WRITE(map->vblank, (adjusted_mode->crtc_vblank_start - 1) |
  346. ((adjusted_mode->crtc_vblank_end - 1) << 16));
  347. REG_WRITE(map->vsync, (adjusted_mode->crtc_vsync_start - 1) |
  348. ((adjusted_mode->crtc_vsync_end - 1) << 16));
  349. }
  350. /* Flush the plane changes */
  351. {
  352. struct drm_crtc_helper_funcs *crtc_funcs =
  353. crtc->helper_private;
  354. crtc_funcs->mode_set_base(crtc, x, y, old_fb);
  355. }
  356. /* setup pipeconf */
  357. pipeconf = REG_READ(map->conf);
  358. /* Set up the display plane register */
  359. dspcntr = REG_READ(map->cntr);
  360. dspcntr |= DISPPLANE_GAMMA_ENABLE;
  361. if (pipe == 0)
  362. dspcntr |= DISPPLANE_SEL_PIPE_A;
  363. else
  364. dspcntr |= DISPPLANE_SEL_PIPE_B;
  365. if (is_mipi)
  366. goto oaktrail_crtc_mode_set_exit;
  367. refclk = dev_priv->core_freq * 1000;
  368. dpll = 0; /*BIT16 = 0 for 100MHz reference */
  369. ok = mrstFindBestPLL(crtc, adjusted_mode->clock, refclk, &clock);
  370. if (!ok) {
  371. dev_dbg(dev->dev, "mrstFindBestPLL fail in oaktrail_crtc_mode_set.\n");
  372. } else {
  373. dev_dbg(dev->dev, "oaktrail_crtc_mode_set pixel clock = %d,"
  374. "m = %x, p1 = %x.\n", clock.dot, clock.m,
  375. clock.p1);
  376. }
  377. fp = oaktrail_m_converts[(clock.m - MRST_M_MIN)] << 8;
  378. dpll |= DPLL_VGA_MODE_DIS;
  379. dpll |= DPLL_VCO_ENABLE;
  380. if (is_lvds)
  381. dpll |= DPLLA_MODE_LVDS;
  382. else
  383. dpll |= DPLLB_MODE_DAC_SERIAL;
  384. if (is_sdvo) {
  385. int sdvo_pixel_multiply =
  386. adjusted_mode->clock / mode->clock;
  387. dpll |= DPLL_DVO_HIGH_SPEED;
  388. dpll |=
  389. (sdvo_pixel_multiply -
  390. 1) << SDVO_MULTIPLIER_SHIFT_HIRES;
  391. }
  392. /* compute bitmask from p1 value */
  393. dpll |= (1 << (clock.p1 - 2)) << 17;
  394. dpll |= DPLL_VCO_ENABLE;
  395. mrstPrintPll("chosen", &clock);
  396. if (dpll & DPLL_VCO_ENABLE) {
  397. REG_WRITE(map->fp0, fp);
  398. REG_WRITE(map->dpll, dpll & ~DPLL_VCO_ENABLE);
  399. REG_READ(map->dpll);
  400. /* Check the DPLLA lock bit PIPEACONF[29] */
  401. udelay(150);
  402. }
  403. REG_WRITE(map->fp0, fp);
  404. REG_WRITE(map->dpll, dpll);
  405. REG_READ(map->dpll);
  406. /* Wait for the clocks to stabilize. */
  407. udelay(150);
  408. /* write it again -- the BIOS does, after all */
  409. REG_WRITE(map->dpll, dpll);
  410. REG_READ(map->dpll);
  411. /* Wait for the clocks to stabilize. */
  412. udelay(150);
  413. REG_WRITE(map->conf, pipeconf);
  414. REG_READ(map->conf);
  415. psb_intel_wait_for_vblank(dev);
  416. REG_WRITE(map->cntr, dspcntr);
  417. psb_intel_wait_for_vblank(dev);
  418. oaktrail_crtc_mode_set_exit:
  419. gma_power_end(dev);
  420. return 0;
  421. }
  422. static bool oaktrail_crtc_mode_fixup(struct drm_crtc *crtc,
  423. const struct drm_display_mode *mode,
  424. struct drm_display_mode *adjusted_mode)
  425. {
  426. return true;
  427. }
  428. static int oaktrail_pipe_set_base(struct drm_crtc *crtc,
  429. int x, int y, struct drm_framebuffer *old_fb)
  430. {
  431. struct drm_device *dev = crtc->dev;
  432. struct drm_psb_private *dev_priv = dev->dev_private;
  433. struct psb_intel_crtc *psb_intel_crtc = to_psb_intel_crtc(crtc);
  434. struct psb_framebuffer *psbfb = to_psb_fb(crtc->fb);
  435. int pipe = psb_intel_crtc->pipe;
  436. const struct psb_offset *map = &dev_priv->regmap[pipe];
  437. unsigned long start, offset;
  438. u32 dspcntr;
  439. int ret = 0;
  440. /* no fb bound */
  441. if (!crtc->fb) {
  442. dev_dbg(dev->dev, "No FB bound\n");
  443. return 0;
  444. }
  445. if (!gma_power_begin(dev, true))
  446. return 0;
  447. start = psbfb->gtt->offset;
  448. offset = y * crtc->fb->pitches[0] + x * (crtc->fb->bits_per_pixel / 8);
  449. REG_WRITE(map->stride, crtc->fb->pitches[0]);
  450. dspcntr = REG_READ(map->cntr);
  451. dspcntr &= ~DISPPLANE_PIXFORMAT_MASK;
  452. switch (crtc->fb->bits_per_pixel) {
  453. case 8:
  454. dspcntr |= DISPPLANE_8BPP;
  455. break;
  456. case 16:
  457. if (crtc->fb->depth == 15)
  458. dspcntr |= DISPPLANE_15_16BPP;
  459. else
  460. dspcntr |= DISPPLANE_16BPP;
  461. break;
  462. case 24:
  463. case 32:
  464. dspcntr |= DISPPLANE_32BPP_NO_ALPHA;
  465. break;
  466. default:
  467. dev_err(dev->dev, "Unknown color depth\n");
  468. ret = -EINVAL;
  469. goto pipe_set_base_exit;
  470. }
  471. REG_WRITE(map->cntr, dspcntr);
  472. REG_WRITE(map->base, offset);
  473. REG_READ(map->base);
  474. REG_WRITE(map->surf, start);
  475. REG_READ(map->surf);
  476. pipe_set_base_exit:
  477. gma_power_end(dev);
  478. return ret;
  479. }
  480. static void oaktrail_crtc_prepare(struct drm_crtc *crtc)
  481. {
  482. struct drm_crtc_helper_funcs *crtc_funcs = crtc->helper_private;
  483. crtc_funcs->dpms(crtc, DRM_MODE_DPMS_OFF);
  484. }
  485. static void oaktrail_crtc_commit(struct drm_crtc *crtc)
  486. {
  487. struct drm_crtc_helper_funcs *crtc_funcs = crtc->helper_private;
  488. crtc_funcs->dpms(crtc, DRM_MODE_DPMS_ON);
  489. }
  490. const struct drm_crtc_helper_funcs oaktrail_helper_funcs = {
  491. .dpms = oaktrail_crtc_dpms,
  492. .mode_fixup = oaktrail_crtc_mode_fixup,
  493. .mode_set = oaktrail_crtc_mode_set,
  494. .mode_set_base = oaktrail_pipe_set_base,
  495. .prepare = oaktrail_crtc_prepare,
  496. .commit = oaktrail_crtc_commit,
  497. };