cdv_intel_display.c 43 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661
  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 "psb_intel_display.h"
  28. #include "power.h"
  29. #include "cdv_device.h"
  30. static bool cdv_intel_find_dp_pll(const struct gma_limit_t *limit,
  31. struct drm_crtc *crtc, int target,
  32. int refclk, struct gma_clock_t *best_clock);
  33. #define CDV_LIMIT_SINGLE_LVDS_96 0
  34. #define CDV_LIMIT_SINGLE_LVDS_100 1
  35. #define CDV_LIMIT_DAC_HDMI_27 2
  36. #define CDV_LIMIT_DAC_HDMI_96 3
  37. #define CDV_LIMIT_DP_27 4
  38. #define CDV_LIMIT_DP_100 5
  39. static const struct gma_limit_t cdv_intel_limits[] = {
  40. { /* CDV_SINGLE_LVDS_96MHz */
  41. .dot = {.min = 20000, .max = 115500},
  42. .vco = {.min = 1800000, .max = 3600000},
  43. .n = {.min = 2, .max = 6},
  44. .m = {.min = 60, .max = 160},
  45. .m1 = {.min = 0, .max = 0},
  46. .m2 = {.min = 58, .max = 158},
  47. .p = {.min = 28, .max = 140},
  48. .p1 = {.min = 2, .max = 10},
  49. .p2 = {.dot_limit = 200000, .p2_slow = 14, .p2_fast = 14},
  50. .find_pll = gma_find_best_pll,
  51. },
  52. { /* CDV_SINGLE_LVDS_100MHz */
  53. .dot = {.min = 20000, .max = 115500},
  54. .vco = {.min = 1800000, .max = 3600000},
  55. .n = {.min = 2, .max = 6},
  56. .m = {.min = 60, .max = 160},
  57. .m1 = {.min = 0, .max = 0},
  58. .m2 = {.min = 58, .max = 158},
  59. .p = {.min = 28, .max = 140},
  60. .p1 = {.min = 2, .max = 10},
  61. /* The single-channel range is 25-112Mhz, and dual-channel
  62. * is 80-224Mhz. Prefer single channel as much as possible.
  63. */
  64. .p2 = {.dot_limit = 200000, .p2_slow = 14, .p2_fast = 14},
  65. .find_pll = gma_find_best_pll,
  66. },
  67. { /* CDV_DAC_HDMI_27MHz */
  68. .dot = {.min = 20000, .max = 400000},
  69. .vco = {.min = 1809000, .max = 3564000},
  70. .n = {.min = 1, .max = 1},
  71. .m = {.min = 67, .max = 132},
  72. .m1 = {.min = 0, .max = 0},
  73. .m2 = {.min = 65, .max = 130},
  74. .p = {.min = 5, .max = 90},
  75. .p1 = {.min = 1, .max = 9},
  76. .p2 = {.dot_limit = 225000, .p2_slow = 10, .p2_fast = 5},
  77. .find_pll = gma_find_best_pll,
  78. },
  79. { /* CDV_DAC_HDMI_96MHz */
  80. .dot = {.min = 20000, .max = 400000},
  81. .vco = {.min = 1800000, .max = 3600000},
  82. .n = {.min = 2, .max = 6},
  83. .m = {.min = 60, .max = 160},
  84. .m1 = {.min = 0, .max = 0},
  85. .m2 = {.min = 58, .max = 158},
  86. .p = {.min = 5, .max = 100},
  87. .p1 = {.min = 1, .max = 10},
  88. .p2 = {.dot_limit = 225000, .p2_slow = 10, .p2_fast = 5},
  89. .find_pll = gma_find_best_pll,
  90. },
  91. { /* CDV_DP_27MHz */
  92. .dot = {.min = 160000, .max = 272000},
  93. .vco = {.min = 1809000, .max = 3564000},
  94. .n = {.min = 1, .max = 1},
  95. .m = {.min = 67, .max = 132},
  96. .m1 = {.min = 0, .max = 0},
  97. .m2 = {.min = 65, .max = 130},
  98. .p = {.min = 5, .max = 90},
  99. .p1 = {.min = 1, .max = 9},
  100. .p2 = {.dot_limit = 225000, .p2_slow = 10, .p2_fast = 10},
  101. .find_pll = cdv_intel_find_dp_pll,
  102. },
  103. { /* CDV_DP_100MHz */
  104. .dot = {.min = 160000, .max = 272000},
  105. .vco = {.min = 1800000, .max = 3600000},
  106. .n = {.min = 2, .max = 6},
  107. .m = {.min = 60, .max = 164},
  108. .m1 = {.min = 0, .max = 0},
  109. .m2 = {.min = 58, .max = 162},
  110. .p = {.min = 5, .max = 100},
  111. .p1 = {.min = 1, .max = 10},
  112. .p2 = {.dot_limit = 225000, .p2_slow = 10, .p2_fast = 10},
  113. .find_pll = cdv_intel_find_dp_pll,
  114. }
  115. };
  116. #define _wait_for(COND, MS, W) ({ \
  117. unsigned long timeout__ = jiffies + msecs_to_jiffies(MS); \
  118. int ret__ = 0; \
  119. while (!(COND)) { \
  120. if (time_after(jiffies, timeout__)) { \
  121. ret__ = -ETIMEDOUT; \
  122. break; \
  123. } \
  124. if (W && !in_dbg_master()) \
  125. msleep(W); \
  126. } \
  127. ret__; \
  128. })
  129. #define wait_for(COND, MS) _wait_for(COND, MS, 1)
  130. int cdv_sb_read(struct drm_device *dev, u32 reg, u32 *val)
  131. {
  132. int ret;
  133. ret = wait_for((REG_READ(SB_PCKT) & SB_BUSY) == 0, 1000);
  134. if (ret) {
  135. DRM_ERROR("timeout waiting for SB to idle before read\n");
  136. return ret;
  137. }
  138. REG_WRITE(SB_ADDR, reg);
  139. REG_WRITE(SB_PCKT,
  140. SET_FIELD(SB_OPCODE_READ, SB_OPCODE) |
  141. SET_FIELD(SB_DEST_DPLL, SB_DEST) |
  142. SET_FIELD(0xf, SB_BYTE_ENABLE));
  143. ret = wait_for((REG_READ(SB_PCKT) & SB_BUSY) == 0, 1000);
  144. if (ret) {
  145. DRM_ERROR("timeout waiting for SB to idle after read\n");
  146. return ret;
  147. }
  148. *val = REG_READ(SB_DATA);
  149. return 0;
  150. }
  151. int cdv_sb_write(struct drm_device *dev, u32 reg, u32 val)
  152. {
  153. int ret;
  154. static bool dpio_debug = true;
  155. u32 temp;
  156. if (dpio_debug) {
  157. if (cdv_sb_read(dev, reg, &temp) == 0)
  158. DRM_DEBUG_KMS("0x%08x: 0x%08x (before)\n", reg, temp);
  159. DRM_DEBUG_KMS("0x%08x: 0x%08x\n", reg, val);
  160. }
  161. ret = wait_for((REG_READ(SB_PCKT) & SB_BUSY) == 0, 1000);
  162. if (ret) {
  163. DRM_ERROR("timeout waiting for SB to idle before write\n");
  164. return ret;
  165. }
  166. REG_WRITE(SB_ADDR, reg);
  167. REG_WRITE(SB_DATA, val);
  168. REG_WRITE(SB_PCKT,
  169. SET_FIELD(SB_OPCODE_WRITE, SB_OPCODE) |
  170. SET_FIELD(SB_DEST_DPLL, SB_DEST) |
  171. SET_FIELD(0xf, SB_BYTE_ENABLE));
  172. ret = wait_for((REG_READ(SB_PCKT) & SB_BUSY) == 0, 1000);
  173. if (ret) {
  174. DRM_ERROR("timeout waiting for SB to idle after write\n");
  175. return ret;
  176. }
  177. if (dpio_debug) {
  178. if (cdv_sb_read(dev, reg, &temp) == 0)
  179. DRM_DEBUG_KMS("0x%08x: 0x%08x (after)\n", reg, temp);
  180. }
  181. return 0;
  182. }
  183. /* Reset the DPIO configuration register. The BIOS does this at every
  184. * mode set.
  185. */
  186. void cdv_sb_reset(struct drm_device *dev)
  187. {
  188. REG_WRITE(DPIO_CFG, 0);
  189. REG_READ(DPIO_CFG);
  190. REG_WRITE(DPIO_CFG, DPIO_MODE_SELECT_0 | DPIO_CMN_RESET_N);
  191. }
  192. /* Unlike most Intel display engines, on Cedarview the DPLL registers
  193. * are behind this sideband bus. They must be programmed while the
  194. * DPLL reference clock is on in the DPLL control register, but before
  195. * the DPLL is enabled in the DPLL control register.
  196. */
  197. static int
  198. cdv_dpll_set_clock_cdv(struct drm_device *dev, struct drm_crtc *crtc,
  199. struct gma_clock_t *clock, bool is_lvds, u32 ddi_select)
  200. {
  201. struct psb_intel_crtc *psb_crtc = to_psb_intel_crtc(crtc);
  202. int pipe = psb_crtc->pipe;
  203. u32 m, n_vco, p;
  204. int ret = 0;
  205. int dpll_reg = (pipe == 0) ? DPLL_A : DPLL_B;
  206. int ref_sfr = (pipe == 0) ? SB_REF_DPLLA : SB_REF_DPLLB;
  207. u32 ref_value;
  208. u32 lane_reg, lane_value;
  209. cdv_sb_reset(dev);
  210. REG_WRITE(dpll_reg, DPLL_SYNCLOCK_ENABLE | DPLL_VGA_MODE_DIS);
  211. udelay(100);
  212. /* Follow the BIOS and write the REF/SFR Register. Hardcoded value */
  213. ref_value = 0x68A701;
  214. cdv_sb_write(dev, SB_REF_SFR(pipe), ref_value);
  215. /* We don't know what the other fields of these regs are, so
  216. * leave them in place.
  217. */
  218. /*
  219. * The BIT 14:13 of 0x8010/0x8030 is used to select the ref clk
  220. * for the pipe A/B. Display spec 1.06 has wrong definition.
  221. * Correct definition is like below:
  222. *
  223. * refclka mean use clock from same PLL
  224. *
  225. * if DPLLA sets 01 and DPLLB sets 01, they use clock from their pll
  226. *
  227. * if DPLLA sets 01 and DPLLB sets 02, both use clk from DPLLA
  228. *
  229. */
  230. ret = cdv_sb_read(dev, ref_sfr, &ref_value);
  231. if (ret)
  232. return ret;
  233. ref_value &= ~(REF_CLK_MASK);
  234. /* use DPLL_A for pipeB on CRT/HDMI */
  235. if (pipe == 1 && !is_lvds && !(ddi_select & DP_MASK)) {
  236. DRM_DEBUG_KMS("use DPLLA for pipe B\n");
  237. ref_value |= REF_CLK_DPLLA;
  238. } else {
  239. DRM_DEBUG_KMS("use their DPLL for pipe A/B\n");
  240. ref_value |= REF_CLK_DPLL;
  241. }
  242. ret = cdv_sb_write(dev, ref_sfr, ref_value);
  243. if (ret)
  244. return ret;
  245. ret = cdv_sb_read(dev, SB_M(pipe), &m);
  246. if (ret)
  247. return ret;
  248. m &= ~SB_M_DIVIDER_MASK;
  249. m |= ((clock->m2) << SB_M_DIVIDER_SHIFT);
  250. ret = cdv_sb_write(dev, SB_M(pipe), m);
  251. if (ret)
  252. return ret;
  253. ret = cdv_sb_read(dev, SB_N_VCO(pipe), &n_vco);
  254. if (ret)
  255. return ret;
  256. /* Follow the BIOS to program the N_DIVIDER REG */
  257. n_vco &= 0xFFFF;
  258. n_vco |= 0x107;
  259. n_vco &= ~(SB_N_VCO_SEL_MASK |
  260. SB_N_DIVIDER_MASK |
  261. SB_N_CB_TUNE_MASK);
  262. n_vco |= ((clock->n) << SB_N_DIVIDER_SHIFT);
  263. if (clock->vco < 2250000) {
  264. n_vco |= (2 << SB_N_CB_TUNE_SHIFT);
  265. n_vco |= (0 << SB_N_VCO_SEL_SHIFT);
  266. } else if (clock->vco < 2750000) {
  267. n_vco |= (1 << SB_N_CB_TUNE_SHIFT);
  268. n_vco |= (1 << SB_N_VCO_SEL_SHIFT);
  269. } else if (clock->vco < 3300000) {
  270. n_vco |= (0 << SB_N_CB_TUNE_SHIFT);
  271. n_vco |= (2 << SB_N_VCO_SEL_SHIFT);
  272. } else {
  273. n_vco |= (0 << SB_N_CB_TUNE_SHIFT);
  274. n_vco |= (3 << SB_N_VCO_SEL_SHIFT);
  275. }
  276. ret = cdv_sb_write(dev, SB_N_VCO(pipe), n_vco);
  277. if (ret)
  278. return ret;
  279. ret = cdv_sb_read(dev, SB_P(pipe), &p);
  280. if (ret)
  281. return ret;
  282. p &= ~(SB_P2_DIVIDER_MASK | SB_P1_DIVIDER_MASK);
  283. p |= SET_FIELD(clock->p1, SB_P1_DIVIDER);
  284. switch (clock->p2) {
  285. case 5:
  286. p |= SET_FIELD(SB_P2_5, SB_P2_DIVIDER);
  287. break;
  288. case 10:
  289. p |= SET_FIELD(SB_P2_10, SB_P2_DIVIDER);
  290. break;
  291. case 14:
  292. p |= SET_FIELD(SB_P2_14, SB_P2_DIVIDER);
  293. break;
  294. case 7:
  295. p |= SET_FIELD(SB_P2_7, SB_P2_DIVIDER);
  296. break;
  297. default:
  298. DRM_ERROR("Bad P2 clock: %d\n", clock->p2);
  299. return -EINVAL;
  300. }
  301. ret = cdv_sb_write(dev, SB_P(pipe), p);
  302. if (ret)
  303. return ret;
  304. if (ddi_select) {
  305. if ((ddi_select & DDI_MASK) == DDI0_SELECT) {
  306. lane_reg = PSB_LANE0;
  307. cdv_sb_read(dev, lane_reg, &lane_value);
  308. lane_value &= ~(LANE_PLL_MASK);
  309. lane_value |= LANE_PLL_ENABLE | LANE_PLL_PIPE(pipe);
  310. cdv_sb_write(dev, lane_reg, lane_value);
  311. lane_reg = PSB_LANE1;
  312. cdv_sb_read(dev, lane_reg, &lane_value);
  313. lane_value &= ~(LANE_PLL_MASK);
  314. lane_value |= LANE_PLL_ENABLE | LANE_PLL_PIPE(pipe);
  315. cdv_sb_write(dev, lane_reg, lane_value);
  316. } else {
  317. lane_reg = PSB_LANE2;
  318. cdv_sb_read(dev, lane_reg, &lane_value);
  319. lane_value &= ~(LANE_PLL_MASK);
  320. lane_value |= LANE_PLL_ENABLE | LANE_PLL_PIPE(pipe);
  321. cdv_sb_write(dev, lane_reg, lane_value);
  322. lane_reg = PSB_LANE3;
  323. cdv_sb_read(dev, lane_reg, &lane_value);
  324. lane_value &= ~(LANE_PLL_MASK);
  325. lane_value |= LANE_PLL_ENABLE | LANE_PLL_PIPE(pipe);
  326. cdv_sb_write(dev, lane_reg, lane_value);
  327. }
  328. }
  329. return 0;
  330. }
  331. static const struct gma_limit_t *cdv_intel_limit(struct drm_crtc *crtc,
  332. int refclk)
  333. {
  334. const struct gma_limit_t *limit;
  335. if (psb_intel_pipe_has_type(crtc, INTEL_OUTPUT_LVDS)) {
  336. /*
  337. * Now only single-channel LVDS is supported on CDV. If it is
  338. * incorrect, please add the dual-channel LVDS.
  339. */
  340. if (refclk == 96000)
  341. limit = &cdv_intel_limits[CDV_LIMIT_SINGLE_LVDS_96];
  342. else
  343. limit = &cdv_intel_limits[CDV_LIMIT_SINGLE_LVDS_100];
  344. } else if (psb_intel_pipe_has_type(crtc, INTEL_OUTPUT_DISPLAYPORT) ||
  345. psb_intel_pipe_has_type(crtc, INTEL_OUTPUT_EDP)) {
  346. if (refclk == 27000)
  347. limit = &cdv_intel_limits[CDV_LIMIT_DP_27];
  348. else
  349. limit = &cdv_intel_limits[CDV_LIMIT_DP_100];
  350. } else {
  351. if (refclk == 27000)
  352. limit = &cdv_intel_limits[CDV_LIMIT_DAC_HDMI_27];
  353. else
  354. limit = &cdv_intel_limits[CDV_LIMIT_DAC_HDMI_96];
  355. }
  356. return limit;
  357. }
  358. /* m1 is reserved as 0 in CDV, n is a ring counter */
  359. static void cdv_intel_clock(int refclk, struct gma_clock_t *clock)
  360. {
  361. clock->m = clock->m2 + 2;
  362. clock->p = clock->p1 * clock->p2;
  363. clock->vco = (refclk * clock->m) / clock->n;
  364. clock->dot = clock->vco / clock->p;
  365. }
  366. static bool cdv_intel_find_dp_pll(const struct gma_limit_t *limit,
  367. struct drm_crtc *crtc, int target,
  368. int refclk,
  369. struct gma_clock_t *best_clock)
  370. {
  371. struct gma_clock_t clock;
  372. if (refclk == 27000) {
  373. if (target < 200000) {
  374. clock.p1 = 2;
  375. clock.p2 = 10;
  376. clock.n = 1;
  377. clock.m1 = 0;
  378. clock.m2 = 118;
  379. } else {
  380. clock.p1 = 1;
  381. clock.p2 = 10;
  382. clock.n = 1;
  383. clock.m1 = 0;
  384. clock.m2 = 98;
  385. }
  386. } else if (refclk == 100000) {
  387. if (target < 200000) {
  388. clock.p1 = 2;
  389. clock.p2 = 10;
  390. clock.n = 5;
  391. clock.m1 = 0;
  392. clock.m2 = 160;
  393. } else {
  394. clock.p1 = 1;
  395. clock.p2 = 10;
  396. clock.n = 5;
  397. clock.m1 = 0;
  398. clock.m2 = 133;
  399. }
  400. } else
  401. return false;
  402. clock.m = clock.m2 + 2;
  403. clock.p = clock.p1 * clock.p2;
  404. clock.vco = (refclk * clock.m) / clock.n;
  405. clock.dot = clock.vco / clock.p;
  406. memcpy(best_clock, &clock, sizeof(struct gma_clock_t));
  407. return true;
  408. }
  409. static int cdv_intel_pipe_set_base(struct drm_crtc *crtc,
  410. int x, int y, struct drm_framebuffer *old_fb)
  411. {
  412. struct drm_device *dev = crtc->dev;
  413. struct drm_psb_private *dev_priv = dev->dev_private;
  414. struct psb_intel_crtc *psb_intel_crtc = to_psb_intel_crtc(crtc);
  415. struct psb_framebuffer *psbfb = to_psb_fb(crtc->fb);
  416. int pipe = psb_intel_crtc->pipe;
  417. const struct psb_offset *map = &dev_priv->regmap[pipe];
  418. unsigned long start, offset;
  419. u32 dspcntr;
  420. int ret = 0;
  421. if (!gma_power_begin(dev, true))
  422. return 0;
  423. /* no fb bound */
  424. if (!crtc->fb) {
  425. dev_err(dev->dev, "No FB bound\n");
  426. goto psb_intel_pipe_cleaner;
  427. }
  428. /* We are displaying this buffer, make sure it is actually loaded
  429. into the GTT */
  430. ret = psb_gtt_pin(psbfb->gtt);
  431. if (ret < 0)
  432. goto psb_intel_pipe_set_base_exit;
  433. start = psbfb->gtt->offset;
  434. offset = y * crtc->fb->pitches[0] + x * (crtc->fb->bits_per_pixel / 8);
  435. REG_WRITE(map->stride, crtc->fb->pitches[0]);
  436. dspcntr = REG_READ(map->cntr);
  437. dspcntr &= ~DISPPLANE_PIXFORMAT_MASK;
  438. switch (crtc->fb->bits_per_pixel) {
  439. case 8:
  440. dspcntr |= DISPPLANE_8BPP;
  441. break;
  442. case 16:
  443. if (crtc->fb->depth == 15)
  444. dspcntr |= DISPPLANE_15_16BPP;
  445. else
  446. dspcntr |= DISPPLANE_16BPP;
  447. break;
  448. case 24:
  449. case 32:
  450. dspcntr |= DISPPLANE_32BPP_NO_ALPHA;
  451. break;
  452. default:
  453. dev_err(dev->dev, "Unknown color depth\n");
  454. ret = -EINVAL;
  455. goto psb_intel_pipe_set_base_exit;
  456. }
  457. REG_WRITE(map->cntr, dspcntr);
  458. dev_dbg(dev->dev,
  459. "Writing base %08lX %08lX %d %d\n", start, offset, x, y);
  460. REG_WRITE(map->base, offset);
  461. REG_READ(map->base);
  462. REG_WRITE(map->surf, start);
  463. REG_READ(map->surf);
  464. psb_intel_pipe_cleaner:
  465. /* If there was a previous display we can now unpin it */
  466. if (old_fb)
  467. psb_gtt_unpin(to_psb_fb(old_fb)->gtt);
  468. psb_intel_pipe_set_base_exit:
  469. gma_power_end(dev);
  470. return ret;
  471. }
  472. #define FIFO_PIPEA (1 << 0)
  473. #define FIFO_PIPEB (1 << 1)
  474. static bool cdv_intel_pipe_enabled(struct drm_device *dev, int pipe)
  475. {
  476. struct drm_crtc *crtc;
  477. struct drm_psb_private *dev_priv = dev->dev_private;
  478. struct psb_intel_crtc *psb_intel_crtc = NULL;
  479. crtc = dev_priv->pipe_to_crtc_mapping[pipe];
  480. psb_intel_crtc = to_psb_intel_crtc(crtc);
  481. if (crtc->fb == NULL || !psb_intel_crtc->active)
  482. return false;
  483. return true;
  484. }
  485. static bool cdv_intel_single_pipe_active (struct drm_device *dev)
  486. {
  487. uint32_t pipe_enabled = 0;
  488. if (cdv_intel_pipe_enabled(dev, 0))
  489. pipe_enabled |= FIFO_PIPEA;
  490. if (cdv_intel_pipe_enabled(dev, 1))
  491. pipe_enabled |= FIFO_PIPEB;
  492. DRM_DEBUG_KMS("pipe enabled %x\n", pipe_enabled);
  493. if (pipe_enabled == FIFO_PIPEA || pipe_enabled == FIFO_PIPEB)
  494. return true;
  495. else
  496. return false;
  497. }
  498. static bool is_pipeb_lvds(struct drm_device *dev, struct drm_crtc *crtc)
  499. {
  500. struct psb_intel_crtc *psb_intel_crtc = to_psb_intel_crtc(crtc);
  501. struct drm_mode_config *mode_config = &dev->mode_config;
  502. struct drm_connector *connector;
  503. if (psb_intel_crtc->pipe != 1)
  504. return false;
  505. list_for_each_entry(connector, &mode_config->connector_list, head) {
  506. struct psb_intel_encoder *psb_intel_encoder =
  507. psb_intel_attached_encoder(connector);
  508. if (!connector->encoder
  509. || connector->encoder->crtc != crtc)
  510. continue;
  511. if (psb_intel_encoder->type == INTEL_OUTPUT_LVDS)
  512. return true;
  513. }
  514. return false;
  515. }
  516. static void cdv_intel_disable_self_refresh (struct drm_device *dev)
  517. {
  518. if (REG_READ(FW_BLC_SELF) & FW_BLC_SELF_EN) {
  519. /* Disable self-refresh before adjust WM */
  520. REG_WRITE(FW_BLC_SELF, (REG_READ(FW_BLC_SELF) & ~FW_BLC_SELF_EN));
  521. REG_READ(FW_BLC_SELF);
  522. cdv_intel_wait_for_vblank(dev);
  523. /* Cedarview workaround to write ovelay plane, which force to leave
  524. * MAX_FIFO state.
  525. */
  526. REG_WRITE(OV_OVADD, 0/*dev_priv->ovl_offset*/);
  527. REG_READ(OV_OVADD);
  528. cdv_intel_wait_for_vblank(dev);
  529. }
  530. }
  531. static void cdv_intel_update_watermark (struct drm_device *dev, struct drm_crtc *crtc)
  532. {
  533. if (cdv_intel_single_pipe_active(dev)) {
  534. u32 fw;
  535. fw = REG_READ(DSPFW1);
  536. fw &= ~DSP_FIFO_SR_WM_MASK;
  537. fw |= (0x7e << DSP_FIFO_SR_WM_SHIFT);
  538. fw &= ~CURSOR_B_FIFO_WM_MASK;
  539. fw |= (0x4 << CURSOR_B_FIFO_WM_SHIFT);
  540. REG_WRITE(DSPFW1, fw);
  541. fw = REG_READ(DSPFW2);
  542. fw &= ~CURSOR_A_FIFO_WM_MASK;
  543. fw |= (0x6 << CURSOR_A_FIFO_WM_SHIFT);
  544. fw &= ~DSP_PLANE_C_FIFO_WM_MASK;
  545. fw |= (0x8 << DSP_PLANE_C_FIFO_WM_SHIFT);
  546. REG_WRITE(DSPFW2, fw);
  547. REG_WRITE(DSPFW3, 0x36000000);
  548. /* ignore FW4 */
  549. if (is_pipeb_lvds(dev, crtc)) {
  550. REG_WRITE(DSPFW5, 0x00040330);
  551. } else {
  552. fw = (3 << DSP_PLANE_B_FIFO_WM1_SHIFT) |
  553. (4 << DSP_PLANE_A_FIFO_WM1_SHIFT) |
  554. (3 << CURSOR_B_FIFO_WM1_SHIFT) |
  555. (4 << CURSOR_FIFO_SR_WM1_SHIFT);
  556. REG_WRITE(DSPFW5, fw);
  557. }
  558. REG_WRITE(DSPFW6, 0x10);
  559. cdv_intel_wait_for_vblank(dev);
  560. /* enable self-refresh for single pipe active */
  561. REG_WRITE(FW_BLC_SELF, FW_BLC_SELF_EN);
  562. REG_READ(FW_BLC_SELF);
  563. cdv_intel_wait_for_vblank(dev);
  564. } else {
  565. /* HW team suggested values... */
  566. REG_WRITE(DSPFW1, 0x3f880808);
  567. REG_WRITE(DSPFW2, 0x0b020202);
  568. REG_WRITE(DSPFW3, 0x24000000);
  569. REG_WRITE(DSPFW4, 0x08030202);
  570. REG_WRITE(DSPFW5, 0x01010101);
  571. REG_WRITE(DSPFW6, 0x1d0);
  572. cdv_intel_wait_for_vblank(dev);
  573. cdv_intel_disable_self_refresh(dev);
  574. }
  575. }
  576. /** Loads the palette/gamma unit for the CRTC with the prepared values */
  577. static void cdv_intel_crtc_load_lut(struct drm_crtc *crtc)
  578. {
  579. struct drm_device *dev = crtc->dev;
  580. struct drm_psb_private *dev_priv = dev->dev_private;
  581. struct psb_intel_crtc *psb_intel_crtc = to_psb_intel_crtc(crtc);
  582. int palreg = PALETTE_A;
  583. int i;
  584. /* The clocks have to be on to load the palette. */
  585. if (!crtc->enabled)
  586. return;
  587. switch (psb_intel_crtc->pipe) {
  588. case 0:
  589. break;
  590. case 1:
  591. palreg = PALETTE_B;
  592. break;
  593. case 2:
  594. palreg = PALETTE_C;
  595. break;
  596. default:
  597. dev_err(dev->dev, "Illegal Pipe Number.\n");
  598. return;
  599. }
  600. if (gma_power_begin(dev, false)) {
  601. for (i = 0; i < 256; i++) {
  602. REG_WRITE(palreg + 4 * i,
  603. ((psb_intel_crtc->lut_r[i] +
  604. psb_intel_crtc->lut_adj[i]) << 16) |
  605. ((psb_intel_crtc->lut_g[i] +
  606. psb_intel_crtc->lut_adj[i]) << 8) |
  607. (psb_intel_crtc->lut_b[i] +
  608. psb_intel_crtc->lut_adj[i]));
  609. }
  610. gma_power_end(dev);
  611. } else {
  612. for (i = 0; i < 256; i++) {
  613. dev_priv->regs.pipe[0].palette[i] =
  614. ((psb_intel_crtc->lut_r[i] +
  615. psb_intel_crtc->lut_adj[i]) << 16) |
  616. ((psb_intel_crtc->lut_g[i] +
  617. psb_intel_crtc->lut_adj[i]) << 8) |
  618. (psb_intel_crtc->lut_b[i] +
  619. psb_intel_crtc->lut_adj[i]);
  620. }
  621. }
  622. }
  623. /**
  624. * Sets the power management mode of the pipe and plane.
  625. *
  626. * This code should probably grow support for turning the cursor off and back
  627. * on appropriately at the same time as we're turning the pipe off/on.
  628. */
  629. static void cdv_intel_crtc_dpms(struct drm_crtc *crtc, int mode)
  630. {
  631. struct drm_device *dev = crtc->dev;
  632. struct drm_psb_private *dev_priv = dev->dev_private;
  633. struct psb_intel_crtc *psb_intel_crtc = to_psb_intel_crtc(crtc);
  634. int pipe = psb_intel_crtc->pipe;
  635. const struct psb_offset *map = &dev_priv->regmap[pipe];
  636. u32 temp;
  637. /* XXX: When our outputs are all unaware of DPMS modes other than off
  638. * and on, we should map those modes to DRM_MODE_DPMS_OFF in the CRTC.
  639. */
  640. cdv_intel_disable_self_refresh(dev);
  641. switch (mode) {
  642. case DRM_MODE_DPMS_ON:
  643. case DRM_MODE_DPMS_STANDBY:
  644. case DRM_MODE_DPMS_SUSPEND:
  645. if (psb_intel_crtc->active)
  646. break;
  647. psb_intel_crtc->active = true;
  648. /* Enable the DPLL */
  649. temp = REG_READ(map->dpll);
  650. if ((temp & DPLL_VCO_ENABLE) == 0) {
  651. REG_WRITE(map->dpll, temp);
  652. REG_READ(map->dpll);
  653. /* Wait for the clocks to stabilize. */
  654. udelay(150);
  655. REG_WRITE(map->dpll, temp | DPLL_VCO_ENABLE);
  656. REG_READ(map->dpll);
  657. /* Wait for the clocks to stabilize. */
  658. udelay(150);
  659. REG_WRITE(map->dpll, temp | DPLL_VCO_ENABLE);
  660. REG_READ(map->dpll);
  661. /* Wait for the clocks to stabilize. */
  662. udelay(150);
  663. }
  664. /* Jim Bish - switch plan and pipe per scott */
  665. /* Enable the plane */
  666. temp = REG_READ(map->cntr);
  667. if ((temp & DISPLAY_PLANE_ENABLE) == 0) {
  668. REG_WRITE(map->cntr,
  669. temp | DISPLAY_PLANE_ENABLE);
  670. /* Flush the plane changes */
  671. REG_WRITE(map->base, REG_READ(map->base));
  672. }
  673. udelay(150);
  674. /* Enable the pipe */
  675. temp = REG_READ(map->conf);
  676. if ((temp & PIPEACONF_ENABLE) == 0)
  677. REG_WRITE(map->conf, temp | PIPEACONF_ENABLE);
  678. temp = REG_READ(map->status);
  679. temp &= ~(0xFFFF);
  680. temp |= PIPE_FIFO_UNDERRUN;
  681. REG_WRITE(map->status, temp);
  682. REG_READ(map->status);
  683. cdv_intel_crtc_load_lut(crtc);
  684. /* Give the overlay scaler a chance to enable
  685. * if it's on this pipe */
  686. /* psb_intel_crtc_dpms_video(crtc, true); TODO */
  687. break;
  688. case DRM_MODE_DPMS_OFF:
  689. if (!psb_intel_crtc->active)
  690. break;
  691. psb_intel_crtc->active = false;
  692. /* Give the overlay scaler a chance to disable
  693. * if it's on this pipe */
  694. /* psb_intel_crtc_dpms_video(crtc, FALSE); TODO */
  695. /* Disable the VGA plane that we never use */
  696. REG_WRITE(VGACNTRL, VGA_DISP_DISABLE);
  697. /* Jim Bish - changed pipe/plane here as well. */
  698. drm_vblank_off(dev, pipe);
  699. /* Wait for vblank for the disable to take effect */
  700. cdv_intel_wait_for_vblank(dev);
  701. /* Next, disable display pipes */
  702. temp = REG_READ(map->conf);
  703. if ((temp & PIPEACONF_ENABLE) != 0) {
  704. REG_WRITE(map->conf, temp & ~PIPEACONF_ENABLE);
  705. REG_READ(map->conf);
  706. }
  707. /* Wait for vblank for the disable to take effect. */
  708. cdv_intel_wait_for_vblank(dev);
  709. udelay(150);
  710. /* Disable display plane */
  711. temp = REG_READ(map->cntr);
  712. if ((temp & DISPLAY_PLANE_ENABLE) != 0) {
  713. REG_WRITE(map->cntr,
  714. temp & ~DISPLAY_PLANE_ENABLE);
  715. /* Flush the plane changes */
  716. REG_WRITE(map->base, REG_READ(map->base));
  717. REG_READ(map->base);
  718. }
  719. temp = REG_READ(map->dpll);
  720. if ((temp & DPLL_VCO_ENABLE) != 0) {
  721. REG_WRITE(map->dpll, temp & ~DPLL_VCO_ENABLE);
  722. REG_READ(map->dpll);
  723. }
  724. /* Wait for the clocks to turn off. */
  725. udelay(150);
  726. break;
  727. }
  728. cdv_intel_update_watermark(dev, crtc);
  729. /*Set FIFO Watermarks*/
  730. REG_WRITE(DSPARB, 0x3F3E);
  731. }
  732. static void cdv_intel_crtc_prepare(struct drm_crtc *crtc)
  733. {
  734. struct drm_crtc_helper_funcs *crtc_funcs = crtc->helper_private;
  735. crtc_funcs->dpms(crtc, DRM_MODE_DPMS_OFF);
  736. }
  737. static void cdv_intel_crtc_commit(struct drm_crtc *crtc)
  738. {
  739. struct drm_crtc_helper_funcs *crtc_funcs = crtc->helper_private;
  740. crtc_funcs->dpms(crtc, DRM_MODE_DPMS_ON);
  741. }
  742. static bool cdv_intel_crtc_mode_fixup(struct drm_crtc *crtc,
  743. const struct drm_display_mode *mode,
  744. struct drm_display_mode *adjusted_mode)
  745. {
  746. return true;
  747. }
  748. /**
  749. * Return the pipe currently connected to the panel fitter,
  750. * or -1 if the panel fitter is not present or not in use
  751. */
  752. static int cdv_intel_panel_fitter_pipe(struct drm_device *dev)
  753. {
  754. u32 pfit_control;
  755. pfit_control = REG_READ(PFIT_CONTROL);
  756. /* See if the panel fitter is in use */
  757. if ((pfit_control & PFIT_ENABLE) == 0)
  758. return -1;
  759. return (pfit_control >> 29) & 0x3;
  760. }
  761. static int cdv_intel_crtc_mode_set(struct drm_crtc *crtc,
  762. struct drm_display_mode *mode,
  763. struct drm_display_mode *adjusted_mode,
  764. int x, int y,
  765. struct drm_framebuffer *old_fb)
  766. {
  767. struct drm_device *dev = crtc->dev;
  768. struct drm_psb_private *dev_priv = dev->dev_private;
  769. struct psb_intel_crtc *psb_intel_crtc = to_psb_intel_crtc(crtc);
  770. int pipe = psb_intel_crtc->pipe;
  771. const struct psb_offset *map = &dev_priv->regmap[pipe];
  772. int refclk;
  773. struct gma_clock_t clock;
  774. u32 dpll = 0, dspcntr, pipeconf;
  775. bool ok;
  776. bool is_crt = false, is_lvds = false, is_tv = false;
  777. bool is_hdmi = false, is_dp = false;
  778. struct drm_mode_config *mode_config = &dev->mode_config;
  779. struct drm_connector *connector;
  780. const struct gma_limit_t *limit;
  781. u32 ddi_select = 0;
  782. bool is_edp = false;
  783. list_for_each_entry(connector, &mode_config->connector_list, head) {
  784. struct psb_intel_encoder *psb_intel_encoder =
  785. psb_intel_attached_encoder(connector);
  786. if (!connector->encoder
  787. || connector->encoder->crtc != crtc)
  788. continue;
  789. ddi_select = psb_intel_encoder->ddi_select;
  790. switch (psb_intel_encoder->type) {
  791. case INTEL_OUTPUT_LVDS:
  792. is_lvds = true;
  793. break;
  794. case INTEL_OUTPUT_TVOUT:
  795. is_tv = true;
  796. break;
  797. case INTEL_OUTPUT_ANALOG:
  798. is_crt = true;
  799. break;
  800. case INTEL_OUTPUT_HDMI:
  801. is_hdmi = true;
  802. break;
  803. case INTEL_OUTPUT_DISPLAYPORT:
  804. is_dp = true;
  805. break;
  806. case INTEL_OUTPUT_EDP:
  807. is_edp = true;
  808. break;
  809. default:
  810. DRM_ERROR("invalid output type.\n");
  811. return 0;
  812. }
  813. }
  814. if (dev_priv->dplla_96mhz)
  815. /* low-end sku, 96/100 mhz */
  816. refclk = 96000;
  817. else
  818. /* high-end sku, 27/100 mhz */
  819. refclk = 27000;
  820. if (is_dp || is_edp) {
  821. /*
  822. * Based on the spec the low-end SKU has only CRT/LVDS. So it is
  823. * unnecessary to consider it for DP/eDP.
  824. * On the high-end SKU, it will use the 27/100M reference clk
  825. * for DP/eDP. When using SSC clock, the ref clk is 100MHz.Otherwise
  826. * it will be 27MHz. From the VBIOS code it seems that the pipe A choose
  827. * 27MHz for DP/eDP while the Pipe B chooses the 100MHz.
  828. */
  829. if (pipe == 0)
  830. refclk = 27000;
  831. else
  832. refclk = 100000;
  833. }
  834. if (is_lvds && dev_priv->lvds_use_ssc) {
  835. refclk = dev_priv->lvds_ssc_freq * 1000;
  836. DRM_DEBUG_KMS("Use SSC reference clock %d Mhz\n", dev_priv->lvds_ssc_freq);
  837. }
  838. drm_mode_debug_printmodeline(adjusted_mode);
  839. limit = psb_intel_crtc->clock_funcs->limit(crtc, refclk);
  840. ok = limit->find_pll(limit, crtc, adjusted_mode->clock, refclk,
  841. &clock);
  842. if (!ok) {
  843. DRM_ERROR("Couldn't find PLL settings for mode! target: %d, actual: %d",
  844. adjusted_mode->clock, clock.dot);
  845. return 0;
  846. }
  847. dpll = DPLL_VGA_MODE_DIS;
  848. if (is_tv) {
  849. /* XXX: just matching BIOS for now */
  850. /* dpll |= PLL_REF_INPUT_TVCLKINBC; */
  851. dpll |= 3;
  852. }
  853. /* dpll |= PLL_REF_INPUT_DREFCLK; */
  854. if (is_dp || is_edp) {
  855. cdv_intel_dp_set_m_n(crtc, mode, adjusted_mode);
  856. } else {
  857. REG_WRITE(PIPE_GMCH_DATA_M(pipe), 0);
  858. REG_WRITE(PIPE_GMCH_DATA_N(pipe), 0);
  859. REG_WRITE(PIPE_DP_LINK_M(pipe), 0);
  860. REG_WRITE(PIPE_DP_LINK_N(pipe), 0);
  861. }
  862. dpll |= DPLL_SYNCLOCK_ENABLE;
  863. /* if (is_lvds)
  864. dpll |= DPLLB_MODE_LVDS;
  865. else
  866. dpll |= DPLLB_MODE_DAC_SERIAL; */
  867. /* dpll |= (2 << 11); */
  868. /* setup pipeconf */
  869. pipeconf = REG_READ(map->conf);
  870. pipeconf &= ~(PIPE_BPC_MASK);
  871. if (is_edp) {
  872. switch (dev_priv->edp.bpp) {
  873. case 24:
  874. pipeconf |= PIPE_8BPC;
  875. break;
  876. case 18:
  877. pipeconf |= PIPE_6BPC;
  878. break;
  879. case 30:
  880. pipeconf |= PIPE_10BPC;
  881. break;
  882. default:
  883. pipeconf |= PIPE_8BPC;
  884. break;
  885. }
  886. } else if (is_lvds) {
  887. /* the BPC will be 6 if it is 18-bit LVDS panel */
  888. if ((REG_READ(LVDS) & LVDS_A3_POWER_MASK) == LVDS_A3_POWER_UP)
  889. pipeconf |= PIPE_8BPC;
  890. else
  891. pipeconf |= PIPE_6BPC;
  892. } else
  893. pipeconf |= PIPE_8BPC;
  894. /* Set up the display plane register */
  895. dspcntr = DISPPLANE_GAMMA_ENABLE;
  896. if (pipe == 0)
  897. dspcntr |= DISPPLANE_SEL_PIPE_A;
  898. else
  899. dspcntr |= DISPPLANE_SEL_PIPE_B;
  900. dspcntr |= DISPLAY_PLANE_ENABLE;
  901. pipeconf |= PIPEACONF_ENABLE;
  902. REG_WRITE(map->dpll, dpll | DPLL_VGA_MODE_DIS | DPLL_SYNCLOCK_ENABLE);
  903. REG_READ(map->dpll);
  904. cdv_dpll_set_clock_cdv(dev, crtc, &clock, is_lvds, ddi_select);
  905. udelay(150);
  906. /* The LVDS pin pair needs to be on before the DPLLs are enabled.
  907. * This is an exception to the general rule that mode_set doesn't turn
  908. * things on.
  909. */
  910. if (is_lvds) {
  911. u32 lvds = REG_READ(LVDS);
  912. lvds |=
  913. LVDS_PORT_EN | LVDS_A0A2_CLKA_POWER_UP |
  914. LVDS_PIPEB_SELECT;
  915. /* Set the B0-B3 data pairs corresponding to
  916. * whether we're going to
  917. * set the DPLLs for dual-channel mode or not.
  918. */
  919. if (clock.p2 == 7)
  920. lvds |= LVDS_B0B3_POWER_UP | LVDS_CLKB_POWER_UP;
  921. else
  922. lvds &= ~(LVDS_B0B3_POWER_UP | LVDS_CLKB_POWER_UP);
  923. /* It would be nice to set 24 vs 18-bit mode (LVDS_A3_POWER_UP)
  924. * appropriately here, but we need to look more
  925. * thoroughly into how panels behave in the two modes.
  926. */
  927. REG_WRITE(LVDS, lvds);
  928. REG_READ(LVDS);
  929. }
  930. dpll |= DPLL_VCO_ENABLE;
  931. /* Disable the panel fitter if it was on our pipe */
  932. if (cdv_intel_panel_fitter_pipe(dev) == pipe)
  933. REG_WRITE(PFIT_CONTROL, 0);
  934. DRM_DEBUG_KMS("Mode for pipe %c:\n", pipe == 0 ? 'A' : 'B');
  935. drm_mode_debug_printmodeline(mode);
  936. REG_WRITE(map->dpll,
  937. (REG_READ(map->dpll) & ~DPLL_LOCK) | DPLL_VCO_ENABLE);
  938. REG_READ(map->dpll);
  939. /* Wait for the clocks to stabilize. */
  940. udelay(150); /* 42 usec w/o calibration, 110 with. rounded up. */
  941. if (!(REG_READ(map->dpll) & DPLL_LOCK)) {
  942. dev_err(dev->dev, "Failed to get DPLL lock\n");
  943. return -EBUSY;
  944. }
  945. {
  946. int sdvo_pixel_multiply = adjusted_mode->clock / mode->clock;
  947. REG_WRITE(map->dpll_md, (0 << DPLL_MD_UDI_DIVIDER_SHIFT) | ((sdvo_pixel_multiply - 1) << DPLL_MD_UDI_MULTIPLIER_SHIFT));
  948. }
  949. REG_WRITE(map->htotal, (adjusted_mode->crtc_hdisplay - 1) |
  950. ((adjusted_mode->crtc_htotal - 1) << 16));
  951. REG_WRITE(map->hblank, (adjusted_mode->crtc_hblank_start - 1) |
  952. ((adjusted_mode->crtc_hblank_end - 1) << 16));
  953. REG_WRITE(map->hsync, (adjusted_mode->crtc_hsync_start - 1) |
  954. ((adjusted_mode->crtc_hsync_end - 1) << 16));
  955. REG_WRITE(map->vtotal, (adjusted_mode->crtc_vdisplay - 1) |
  956. ((adjusted_mode->crtc_vtotal - 1) << 16));
  957. REG_WRITE(map->vblank, (adjusted_mode->crtc_vblank_start - 1) |
  958. ((adjusted_mode->crtc_vblank_end - 1) << 16));
  959. REG_WRITE(map->vsync, (adjusted_mode->crtc_vsync_start - 1) |
  960. ((adjusted_mode->crtc_vsync_end - 1) << 16));
  961. /* pipesrc and dspsize control the size that is scaled from,
  962. * which should always be the user's requested size.
  963. */
  964. REG_WRITE(map->size,
  965. ((mode->vdisplay - 1) << 16) | (mode->hdisplay - 1));
  966. REG_WRITE(map->pos, 0);
  967. REG_WRITE(map->src,
  968. ((mode->hdisplay - 1) << 16) | (mode->vdisplay - 1));
  969. REG_WRITE(map->conf, pipeconf);
  970. REG_READ(map->conf);
  971. cdv_intel_wait_for_vblank(dev);
  972. REG_WRITE(map->cntr, dspcntr);
  973. /* Flush the plane changes */
  974. {
  975. struct drm_crtc_helper_funcs *crtc_funcs =
  976. crtc->helper_private;
  977. crtc_funcs->mode_set_base(crtc, x, y, old_fb);
  978. }
  979. cdv_intel_wait_for_vblank(dev);
  980. return 0;
  981. }
  982. /**
  983. * Save HW states of giving crtc
  984. */
  985. static void cdv_intel_crtc_save(struct drm_crtc *crtc)
  986. {
  987. struct drm_device *dev = crtc->dev;
  988. struct drm_psb_private *dev_priv = dev->dev_private;
  989. struct psb_intel_crtc *psb_intel_crtc = to_psb_intel_crtc(crtc);
  990. struct psb_intel_crtc_state *crtc_state = psb_intel_crtc->crtc_state;
  991. const struct psb_offset *map = &dev_priv->regmap[psb_intel_crtc->pipe];
  992. uint32_t paletteReg;
  993. int i;
  994. if (!crtc_state) {
  995. dev_dbg(dev->dev, "No CRTC state found\n");
  996. return;
  997. }
  998. crtc_state->saveDSPCNTR = REG_READ(map->cntr);
  999. crtc_state->savePIPECONF = REG_READ(map->conf);
  1000. crtc_state->savePIPESRC = REG_READ(map->src);
  1001. crtc_state->saveFP0 = REG_READ(map->fp0);
  1002. crtc_state->saveFP1 = REG_READ(map->fp1);
  1003. crtc_state->saveDPLL = REG_READ(map->dpll);
  1004. crtc_state->saveHTOTAL = REG_READ(map->htotal);
  1005. crtc_state->saveHBLANK = REG_READ(map->hblank);
  1006. crtc_state->saveHSYNC = REG_READ(map->hsync);
  1007. crtc_state->saveVTOTAL = REG_READ(map->vtotal);
  1008. crtc_state->saveVBLANK = REG_READ(map->vblank);
  1009. crtc_state->saveVSYNC = REG_READ(map->vsync);
  1010. crtc_state->saveDSPSTRIDE = REG_READ(map->stride);
  1011. /*NOTE: DSPSIZE DSPPOS only for psb*/
  1012. crtc_state->saveDSPSIZE = REG_READ(map->size);
  1013. crtc_state->saveDSPPOS = REG_READ(map->pos);
  1014. crtc_state->saveDSPBASE = REG_READ(map->base);
  1015. DRM_DEBUG("(%x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x)\n",
  1016. crtc_state->saveDSPCNTR,
  1017. crtc_state->savePIPECONF,
  1018. crtc_state->savePIPESRC,
  1019. crtc_state->saveFP0,
  1020. crtc_state->saveFP1,
  1021. crtc_state->saveDPLL,
  1022. crtc_state->saveHTOTAL,
  1023. crtc_state->saveHBLANK,
  1024. crtc_state->saveHSYNC,
  1025. crtc_state->saveVTOTAL,
  1026. crtc_state->saveVBLANK,
  1027. crtc_state->saveVSYNC,
  1028. crtc_state->saveDSPSTRIDE,
  1029. crtc_state->saveDSPSIZE,
  1030. crtc_state->saveDSPPOS,
  1031. crtc_state->saveDSPBASE
  1032. );
  1033. paletteReg = map->palette;
  1034. for (i = 0; i < 256; ++i)
  1035. crtc_state->savePalette[i] = REG_READ(paletteReg + (i << 2));
  1036. }
  1037. /**
  1038. * Restore HW states of giving crtc
  1039. */
  1040. static void cdv_intel_crtc_restore(struct drm_crtc *crtc)
  1041. {
  1042. struct drm_device *dev = crtc->dev;
  1043. struct drm_psb_private *dev_priv = dev->dev_private;
  1044. struct psb_intel_crtc *psb_intel_crtc = to_psb_intel_crtc(crtc);
  1045. struct psb_intel_crtc_state *crtc_state = psb_intel_crtc->crtc_state;
  1046. const struct psb_offset *map = &dev_priv->regmap[psb_intel_crtc->pipe];
  1047. uint32_t paletteReg;
  1048. int i;
  1049. if (!crtc_state) {
  1050. dev_dbg(dev->dev, "No crtc state\n");
  1051. return;
  1052. }
  1053. DRM_DEBUG(
  1054. "current:(%x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x)\n",
  1055. REG_READ(map->cntr),
  1056. REG_READ(map->conf),
  1057. REG_READ(map->src),
  1058. REG_READ(map->fp0),
  1059. REG_READ(map->fp1),
  1060. REG_READ(map->dpll),
  1061. REG_READ(map->htotal),
  1062. REG_READ(map->hblank),
  1063. REG_READ(map->hsync),
  1064. REG_READ(map->vtotal),
  1065. REG_READ(map->vblank),
  1066. REG_READ(map->vsync),
  1067. REG_READ(map->stride),
  1068. REG_READ(map->size),
  1069. REG_READ(map->pos),
  1070. REG_READ(map->base)
  1071. );
  1072. DRM_DEBUG(
  1073. "saved: (%x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x)\n",
  1074. crtc_state->saveDSPCNTR,
  1075. crtc_state->savePIPECONF,
  1076. crtc_state->savePIPESRC,
  1077. crtc_state->saveFP0,
  1078. crtc_state->saveFP1,
  1079. crtc_state->saveDPLL,
  1080. crtc_state->saveHTOTAL,
  1081. crtc_state->saveHBLANK,
  1082. crtc_state->saveHSYNC,
  1083. crtc_state->saveVTOTAL,
  1084. crtc_state->saveVBLANK,
  1085. crtc_state->saveVSYNC,
  1086. crtc_state->saveDSPSTRIDE,
  1087. crtc_state->saveDSPSIZE,
  1088. crtc_state->saveDSPPOS,
  1089. crtc_state->saveDSPBASE
  1090. );
  1091. if (crtc_state->saveDPLL & DPLL_VCO_ENABLE) {
  1092. REG_WRITE(map->dpll,
  1093. crtc_state->saveDPLL & ~DPLL_VCO_ENABLE);
  1094. REG_READ(map->dpll);
  1095. DRM_DEBUG("write dpll: %x\n",
  1096. REG_READ(map->dpll));
  1097. udelay(150);
  1098. }
  1099. REG_WRITE(map->fp0, crtc_state->saveFP0);
  1100. REG_READ(map->fp0);
  1101. REG_WRITE(map->fp1, crtc_state->saveFP1);
  1102. REG_READ(map->fp1);
  1103. REG_WRITE(map->dpll, crtc_state->saveDPLL);
  1104. REG_READ(map->dpll);
  1105. udelay(150);
  1106. REG_WRITE(map->htotal, crtc_state->saveHTOTAL);
  1107. REG_WRITE(map->hblank, crtc_state->saveHBLANK);
  1108. REG_WRITE(map->hsync, crtc_state->saveHSYNC);
  1109. REG_WRITE(map->vtotal, crtc_state->saveVTOTAL);
  1110. REG_WRITE(map->vblank, crtc_state->saveVBLANK);
  1111. REG_WRITE(map->vsync, crtc_state->saveVSYNC);
  1112. REG_WRITE(map->stride, crtc_state->saveDSPSTRIDE);
  1113. REG_WRITE(map->size, crtc_state->saveDSPSIZE);
  1114. REG_WRITE(map->pos, crtc_state->saveDSPPOS);
  1115. REG_WRITE(map->src, crtc_state->savePIPESRC);
  1116. REG_WRITE(map->base, crtc_state->saveDSPBASE);
  1117. REG_WRITE(map->conf, crtc_state->savePIPECONF);
  1118. cdv_intel_wait_for_vblank(dev);
  1119. REG_WRITE(map->cntr, crtc_state->saveDSPCNTR);
  1120. REG_WRITE(map->base, crtc_state->saveDSPBASE);
  1121. cdv_intel_wait_for_vblank(dev);
  1122. paletteReg = map->palette;
  1123. for (i = 0; i < 256; ++i)
  1124. REG_WRITE(paletteReg + (i << 2), crtc_state->savePalette[i]);
  1125. }
  1126. static int cdv_intel_crtc_cursor_set(struct drm_crtc *crtc,
  1127. struct drm_file *file_priv,
  1128. uint32_t handle,
  1129. uint32_t width, uint32_t height)
  1130. {
  1131. struct drm_device *dev = crtc->dev;
  1132. struct psb_intel_crtc *psb_intel_crtc = to_psb_intel_crtc(crtc);
  1133. int pipe = psb_intel_crtc->pipe;
  1134. uint32_t control = (pipe == 0) ? CURACNTR : CURBCNTR;
  1135. uint32_t base = (pipe == 0) ? CURABASE : CURBBASE;
  1136. uint32_t temp;
  1137. size_t addr = 0;
  1138. struct gtt_range *gt;
  1139. struct drm_gem_object *obj;
  1140. int ret = 0;
  1141. /* if we want to turn of the cursor ignore width and height */
  1142. if (!handle) {
  1143. /* turn off the cursor */
  1144. temp = CURSOR_MODE_DISABLE;
  1145. if (gma_power_begin(dev, false)) {
  1146. REG_WRITE(control, temp);
  1147. REG_WRITE(base, 0);
  1148. gma_power_end(dev);
  1149. }
  1150. /* unpin the old GEM object */
  1151. if (psb_intel_crtc->cursor_obj) {
  1152. gt = container_of(psb_intel_crtc->cursor_obj,
  1153. struct gtt_range, gem);
  1154. psb_gtt_unpin(gt);
  1155. drm_gem_object_unreference(psb_intel_crtc->cursor_obj);
  1156. psb_intel_crtc->cursor_obj = NULL;
  1157. }
  1158. return 0;
  1159. }
  1160. /* Currently we only support 64x64 cursors */
  1161. if (width != 64 || height != 64) {
  1162. dev_dbg(dev->dev, "we currently only support 64x64 cursors\n");
  1163. return -EINVAL;
  1164. }
  1165. obj = drm_gem_object_lookup(dev, file_priv, handle);
  1166. if (!obj)
  1167. return -ENOENT;
  1168. if (obj->size < width * height * 4) {
  1169. dev_dbg(dev->dev, "buffer is to small\n");
  1170. ret = -ENOMEM;
  1171. goto unref_cursor;
  1172. }
  1173. gt = container_of(obj, struct gtt_range, gem);
  1174. /* Pin the memory into the GTT */
  1175. ret = psb_gtt_pin(gt);
  1176. if (ret) {
  1177. dev_err(dev->dev, "Can not pin down handle 0x%x\n", handle);
  1178. goto unref_cursor;
  1179. }
  1180. addr = gt->offset; /* Or resource.start ??? */
  1181. psb_intel_crtc->cursor_addr = addr;
  1182. temp = 0;
  1183. /* set the pipe for the cursor */
  1184. temp |= (pipe << 28);
  1185. temp |= CURSOR_MODE_64_ARGB_AX | MCURSOR_GAMMA_ENABLE;
  1186. if (gma_power_begin(dev, false)) {
  1187. REG_WRITE(control, temp);
  1188. REG_WRITE(base, addr);
  1189. gma_power_end(dev);
  1190. }
  1191. /* unpin the old GEM object */
  1192. if (psb_intel_crtc->cursor_obj) {
  1193. gt = container_of(psb_intel_crtc->cursor_obj,
  1194. struct gtt_range, gem);
  1195. psb_gtt_unpin(gt);
  1196. drm_gem_object_unreference(psb_intel_crtc->cursor_obj);
  1197. }
  1198. psb_intel_crtc->cursor_obj = obj;
  1199. return ret;
  1200. unref_cursor:
  1201. drm_gem_object_unreference(obj);
  1202. return ret;
  1203. }
  1204. static int cdv_intel_crtc_cursor_move(struct drm_crtc *crtc, int x, int y)
  1205. {
  1206. struct drm_device *dev = crtc->dev;
  1207. struct psb_intel_crtc *psb_intel_crtc = to_psb_intel_crtc(crtc);
  1208. int pipe = psb_intel_crtc->pipe;
  1209. uint32_t temp = 0;
  1210. uint32_t adder;
  1211. if (x < 0) {
  1212. temp |= (CURSOR_POS_SIGN << CURSOR_X_SHIFT);
  1213. x = -x;
  1214. }
  1215. if (y < 0) {
  1216. temp |= (CURSOR_POS_SIGN << CURSOR_Y_SHIFT);
  1217. y = -y;
  1218. }
  1219. temp |= ((x & CURSOR_POS_MASK) << CURSOR_X_SHIFT);
  1220. temp |= ((y & CURSOR_POS_MASK) << CURSOR_Y_SHIFT);
  1221. adder = psb_intel_crtc->cursor_addr;
  1222. if (gma_power_begin(dev, false)) {
  1223. REG_WRITE((pipe == 0) ? CURAPOS : CURBPOS, temp);
  1224. REG_WRITE((pipe == 0) ? CURABASE : CURBBASE, adder);
  1225. gma_power_end(dev);
  1226. }
  1227. return 0;
  1228. }
  1229. static void cdv_intel_crtc_gamma_set(struct drm_crtc *crtc, u16 *red,
  1230. u16 *green, u16 *blue, uint32_t start, uint32_t size)
  1231. {
  1232. struct psb_intel_crtc *psb_intel_crtc = to_psb_intel_crtc(crtc);
  1233. int i;
  1234. int end = (start + size > 256) ? 256 : start + size;
  1235. for (i = start; i < end; i++) {
  1236. psb_intel_crtc->lut_r[i] = red[i] >> 8;
  1237. psb_intel_crtc->lut_g[i] = green[i] >> 8;
  1238. psb_intel_crtc->lut_b[i] = blue[i] >> 8;
  1239. }
  1240. cdv_intel_crtc_load_lut(crtc);
  1241. }
  1242. static int cdv_crtc_set_config(struct drm_mode_set *set)
  1243. {
  1244. int ret = 0;
  1245. struct drm_device *dev = set->crtc->dev;
  1246. struct drm_psb_private *dev_priv = dev->dev_private;
  1247. if (!dev_priv->rpm_enabled)
  1248. return drm_crtc_helper_set_config(set);
  1249. pm_runtime_forbid(&dev->pdev->dev);
  1250. ret = drm_crtc_helper_set_config(set);
  1251. pm_runtime_allow(&dev->pdev->dev);
  1252. return ret;
  1253. }
  1254. /** Derive the pixel clock for the given refclk and divisors for 8xx chips. */
  1255. /* FIXME: why are we using this, should it be cdv_ in this tree ? */
  1256. static void i8xx_clock(int refclk, struct gma_clock_t *clock)
  1257. {
  1258. clock->m = 5 * (clock->m1 + 2) + (clock->m2 + 2);
  1259. clock->p = clock->p1 * clock->p2;
  1260. clock->vco = refclk * clock->m / (clock->n + 2);
  1261. clock->dot = clock->vco / clock->p;
  1262. }
  1263. /* Returns the clock of the currently programmed mode of the given pipe. */
  1264. static int cdv_intel_crtc_clock_get(struct drm_device *dev,
  1265. struct drm_crtc *crtc)
  1266. {
  1267. struct drm_psb_private *dev_priv = dev->dev_private;
  1268. struct psb_intel_crtc *psb_intel_crtc = to_psb_intel_crtc(crtc);
  1269. int pipe = psb_intel_crtc->pipe;
  1270. const struct psb_offset *map = &dev_priv->regmap[pipe];
  1271. u32 dpll;
  1272. u32 fp;
  1273. struct gma_clock_t clock;
  1274. bool is_lvds;
  1275. struct psb_pipe *p = &dev_priv->regs.pipe[pipe];
  1276. if (gma_power_begin(dev, false)) {
  1277. dpll = REG_READ(map->dpll);
  1278. if ((dpll & DISPLAY_RATE_SELECT_FPA1) == 0)
  1279. fp = REG_READ(map->fp0);
  1280. else
  1281. fp = REG_READ(map->fp1);
  1282. is_lvds = (pipe == 1) && (REG_READ(LVDS) & LVDS_PORT_EN);
  1283. gma_power_end(dev);
  1284. } else {
  1285. dpll = p->dpll;
  1286. if ((dpll & DISPLAY_RATE_SELECT_FPA1) == 0)
  1287. fp = p->fp0;
  1288. else
  1289. fp = p->fp1;
  1290. is_lvds = (pipe == 1) &&
  1291. (dev_priv->regs.psb.saveLVDS & LVDS_PORT_EN);
  1292. }
  1293. clock.m1 = (fp & FP_M1_DIV_MASK) >> FP_M1_DIV_SHIFT;
  1294. clock.m2 = (fp & FP_M2_DIV_MASK) >> FP_M2_DIV_SHIFT;
  1295. clock.n = (fp & FP_N_DIV_MASK) >> FP_N_DIV_SHIFT;
  1296. if (is_lvds) {
  1297. clock.p1 =
  1298. ffs((dpll &
  1299. DPLL_FPA01_P1_POST_DIV_MASK_I830_LVDS) >>
  1300. DPLL_FPA01_P1_POST_DIV_SHIFT);
  1301. if (clock.p1 == 0) {
  1302. clock.p1 = 4;
  1303. dev_err(dev->dev, "PLL %d\n", dpll);
  1304. }
  1305. clock.p2 = 14;
  1306. if ((dpll & PLL_REF_INPUT_MASK) ==
  1307. PLLB_REF_INPUT_SPREADSPECTRUMIN) {
  1308. /* XXX: might not be 66MHz */
  1309. i8xx_clock(66000, &clock);
  1310. } else
  1311. i8xx_clock(48000, &clock);
  1312. } else {
  1313. if (dpll & PLL_P1_DIVIDE_BY_TWO)
  1314. clock.p1 = 2;
  1315. else {
  1316. clock.p1 =
  1317. ((dpll &
  1318. DPLL_FPA01_P1_POST_DIV_MASK_I830) >>
  1319. DPLL_FPA01_P1_POST_DIV_SHIFT) + 2;
  1320. }
  1321. if (dpll & PLL_P2_DIVIDE_BY_4)
  1322. clock.p2 = 4;
  1323. else
  1324. clock.p2 = 2;
  1325. i8xx_clock(48000, &clock);
  1326. }
  1327. /* XXX: It would be nice to validate the clocks, but we can't reuse
  1328. * i830PllIsValid() because it relies on the xf86_config connector
  1329. * configuration being accurate, which it isn't necessarily.
  1330. */
  1331. return clock.dot;
  1332. }
  1333. /** Returns the currently programmed mode of the given pipe. */
  1334. struct drm_display_mode *cdv_intel_crtc_mode_get(struct drm_device *dev,
  1335. struct drm_crtc *crtc)
  1336. {
  1337. struct psb_intel_crtc *psb_intel_crtc = to_psb_intel_crtc(crtc);
  1338. int pipe = psb_intel_crtc->pipe;
  1339. struct drm_psb_private *dev_priv = dev->dev_private;
  1340. struct psb_pipe *p = &dev_priv->regs.pipe[pipe];
  1341. const struct psb_offset *map = &dev_priv->regmap[pipe];
  1342. struct drm_display_mode *mode;
  1343. int htot;
  1344. int hsync;
  1345. int vtot;
  1346. int vsync;
  1347. if (gma_power_begin(dev, false)) {
  1348. htot = REG_READ(map->htotal);
  1349. hsync = REG_READ(map->hsync);
  1350. vtot = REG_READ(map->vtotal);
  1351. vsync = REG_READ(map->vsync);
  1352. gma_power_end(dev);
  1353. } else {
  1354. htot = p->htotal;
  1355. hsync = p->hsync;
  1356. vtot = p->vtotal;
  1357. vsync = p->vsync;
  1358. }
  1359. mode = kzalloc(sizeof(*mode), GFP_KERNEL);
  1360. if (!mode)
  1361. return NULL;
  1362. mode->clock = cdv_intel_crtc_clock_get(dev, crtc);
  1363. mode->hdisplay = (htot & 0xffff) + 1;
  1364. mode->htotal = ((htot & 0xffff0000) >> 16) + 1;
  1365. mode->hsync_start = (hsync & 0xffff) + 1;
  1366. mode->hsync_end = ((hsync & 0xffff0000) >> 16) + 1;
  1367. mode->vdisplay = (vtot & 0xffff) + 1;
  1368. mode->vtotal = ((vtot & 0xffff0000) >> 16) + 1;
  1369. mode->vsync_start = (vsync & 0xffff) + 1;
  1370. mode->vsync_end = ((vsync & 0xffff0000) >> 16) + 1;
  1371. drm_mode_set_name(mode);
  1372. drm_mode_set_crtcinfo(mode, 0);
  1373. return mode;
  1374. }
  1375. static void cdv_intel_crtc_destroy(struct drm_crtc *crtc)
  1376. {
  1377. struct psb_intel_crtc *psb_intel_crtc = to_psb_intel_crtc(crtc);
  1378. kfree(psb_intel_crtc->crtc_state);
  1379. drm_crtc_cleanup(crtc);
  1380. kfree(psb_intel_crtc);
  1381. }
  1382. static void cdv_intel_crtc_disable(struct drm_crtc *crtc)
  1383. {
  1384. struct gtt_range *gt;
  1385. struct drm_crtc_helper_funcs *crtc_funcs = crtc->helper_private;
  1386. crtc_funcs->dpms(crtc, DRM_MODE_DPMS_OFF);
  1387. if (crtc->fb) {
  1388. gt = to_psb_fb(crtc->fb)->gtt;
  1389. psb_gtt_unpin(gt);
  1390. }
  1391. }
  1392. const struct drm_crtc_helper_funcs cdv_intel_helper_funcs = {
  1393. .dpms = cdv_intel_crtc_dpms,
  1394. .mode_fixup = cdv_intel_crtc_mode_fixup,
  1395. .mode_set = cdv_intel_crtc_mode_set,
  1396. .mode_set_base = cdv_intel_pipe_set_base,
  1397. .prepare = cdv_intel_crtc_prepare,
  1398. .commit = cdv_intel_crtc_commit,
  1399. .disable = cdv_intel_crtc_disable,
  1400. };
  1401. const struct drm_crtc_funcs cdv_intel_crtc_funcs = {
  1402. .save = cdv_intel_crtc_save,
  1403. .restore = cdv_intel_crtc_restore,
  1404. .cursor_set = cdv_intel_crtc_cursor_set,
  1405. .cursor_move = cdv_intel_crtc_cursor_move,
  1406. .gamma_set = cdv_intel_crtc_gamma_set,
  1407. .set_config = cdv_crtc_set_config,
  1408. .destroy = cdv_intel_crtc_destroy,
  1409. };
  1410. const struct gma_clock_funcs cdv_clock_funcs = {
  1411. .clock = cdv_intel_clock,
  1412. .limit = cdv_intel_limit,
  1413. .pll_is_valid = gma_pll_is_valid,
  1414. };