intel_dsi.c 32 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114
  1. /*
  2. * Copyright © 2013 Intel Corporation
  3. *
  4. * Permission is hereby granted, free of charge, to any person obtaining a
  5. * copy of this software and associated documentation files (the "Software"),
  6. * to deal in the Software without restriction, including without limitation
  7. * the rights to use, copy, modify, merge, publish, distribute, sublicense,
  8. * and/or sell copies of the Software, and to permit persons to whom the
  9. * Software is furnished to do so, subject to the following conditions:
  10. *
  11. * The above copyright notice and this permission notice (including the next
  12. * paragraph) shall be included in all copies or substantial portions of the
  13. * Software.
  14. *
  15. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  16. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  17. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
  18. * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  19. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
  20. * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
  21. * DEALINGS IN THE SOFTWARE.
  22. *
  23. * Author: Jani Nikula <jani.nikula@intel.com>
  24. */
  25. #include <drm/drmP.h>
  26. #include <drm/drm_atomic_helper.h>
  27. #include <drm/drm_crtc.h>
  28. #include <drm/drm_edid.h>
  29. #include <drm/i915_drm.h>
  30. #include <drm/drm_panel.h>
  31. #include <drm/drm_mipi_dsi.h>
  32. #include <linux/slab.h>
  33. #include "i915_drv.h"
  34. #include "intel_drv.h"
  35. #include "intel_dsi.h"
  36. static const struct {
  37. u16 panel_id;
  38. struct drm_panel * (*init)(struct intel_dsi *intel_dsi, u16 panel_id);
  39. } intel_dsi_drivers[] = {
  40. {
  41. .panel_id = MIPI_DSI_GENERIC_PANEL_ID,
  42. .init = vbt_panel_init,
  43. },
  44. };
  45. static void wait_for_dsi_fifo_empty(struct intel_dsi *intel_dsi, enum port port)
  46. {
  47. struct drm_encoder *encoder = &intel_dsi->base.base;
  48. struct drm_device *dev = encoder->dev;
  49. struct drm_i915_private *dev_priv = dev->dev_private;
  50. u32 mask;
  51. mask = LP_CTRL_FIFO_EMPTY | HS_CTRL_FIFO_EMPTY |
  52. LP_DATA_FIFO_EMPTY | HS_DATA_FIFO_EMPTY;
  53. if (wait_for((I915_READ(MIPI_GEN_FIFO_STAT(port)) & mask) == mask, 100))
  54. DRM_ERROR("DPI FIFOs are not empty\n");
  55. }
  56. static void write_data(struct drm_i915_private *dev_priv, u32 reg,
  57. const u8 *data, u32 len)
  58. {
  59. u32 i, j;
  60. for (i = 0; i < len; i += 4) {
  61. u32 val = 0;
  62. for (j = 0; j < min_t(u32, len - i, 4); j++)
  63. val |= *data++ << 8 * j;
  64. I915_WRITE(reg, val);
  65. }
  66. }
  67. static void read_data(struct drm_i915_private *dev_priv, u32 reg,
  68. u8 *data, u32 len)
  69. {
  70. u32 i, j;
  71. for (i = 0; i < len; i += 4) {
  72. u32 val = I915_READ(reg);
  73. for (j = 0; j < min_t(u32, len - i, 4); j++)
  74. *data++ = val >> 8 * j;
  75. }
  76. }
  77. static ssize_t intel_dsi_host_transfer(struct mipi_dsi_host *host,
  78. const struct mipi_dsi_msg *msg)
  79. {
  80. struct intel_dsi_host *intel_dsi_host = to_intel_dsi_host(host);
  81. struct drm_device *dev = intel_dsi_host->intel_dsi->base.base.dev;
  82. struct drm_i915_private *dev_priv = dev->dev_private;
  83. enum port port = intel_dsi_host->port;
  84. struct mipi_dsi_packet packet;
  85. ssize_t ret;
  86. const u8 *header, *data;
  87. u32 data_reg, data_mask, ctrl_reg, ctrl_mask;
  88. ret = mipi_dsi_create_packet(&packet, msg);
  89. if (ret < 0)
  90. return ret;
  91. header = packet.header;
  92. data = packet.payload;
  93. if (msg->flags & MIPI_DSI_MSG_USE_LPM) {
  94. data_reg = MIPI_LP_GEN_DATA(port);
  95. data_mask = LP_DATA_FIFO_FULL;
  96. ctrl_reg = MIPI_LP_GEN_CTRL(port);
  97. ctrl_mask = LP_CTRL_FIFO_FULL;
  98. } else {
  99. data_reg = MIPI_HS_GEN_DATA(port);
  100. data_mask = HS_DATA_FIFO_FULL;
  101. ctrl_reg = MIPI_HS_GEN_CTRL(port);
  102. ctrl_mask = HS_CTRL_FIFO_FULL;
  103. }
  104. /* note: this is never true for reads */
  105. if (packet.payload_length) {
  106. if (wait_for((I915_READ(MIPI_GEN_FIFO_STAT(port)) & data_mask) == 0, 50))
  107. DRM_ERROR("Timeout waiting for HS/LP DATA FIFO !full\n");
  108. write_data(dev_priv, data_reg, packet.payload,
  109. packet.payload_length);
  110. }
  111. if (msg->rx_len) {
  112. I915_WRITE(MIPI_INTR_STAT(port), GEN_READ_DATA_AVAIL);
  113. }
  114. if (wait_for((I915_READ(MIPI_GEN_FIFO_STAT(port)) & ctrl_mask) == 0, 50)) {
  115. DRM_ERROR("Timeout waiting for HS/LP CTRL FIFO !full\n");
  116. }
  117. I915_WRITE(ctrl_reg, header[2] << 16 | header[1] << 8 | header[0]);
  118. /* ->rx_len is set only for reads */
  119. if (msg->rx_len) {
  120. data_mask = GEN_READ_DATA_AVAIL;
  121. if (wait_for((I915_READ(MIPI_INTR_STAT(port)) & data_mask) == data_mask, 50))
  122. DRM_ERROR("Timeout waiting for read data.\n");
  123. read_data(dev_priv, data_reg, msg->rx_buf, msg->rx_len);
  124. }
  125. /* XXX: fix for reads and writes */
  126. return 4 + packet.payload_length;
  127. }
  128. static int intel_dsi_host_attach(struct mipi_dsi_host *host,
  129. struct mipi_dsi_device *dsi)
  130. {
  131. return 0;
  132. }
  133. static int intel_dsi_host_detach(struct mipi_dsi_host *host,
  134. struct mipi_dsi_device *dsi)
  135. {
  136. return 0;
  137. }
  138. static const struct mipi_dsi_host_ops intel_dsi_host_ops = {
  139. .attach = intel_dsi_host_attach,
  140. .detach = intel_dsi_host_detach,
  141. .transfer = intel_dsi_host_transfer,
  142. };
  143. static struct intel_dsi_host *intel_dsi_host_init(struct intel_dsi *intel_dsi,
  144. enum port port)
  145. {
  146. struct intel_dsi_host *host;
  147. struct mipi_dsi_device *device;
  148. host = kzalloc(sizeof(*host), GFP_KERNEL);
  149. if (!host)
  150. return NULL;
  151. host->base.ops = &intel_dsi_host_ops;
  152. host->intel_dsi = intel_dsi;
  153. host->port = port;
  154. /*
  155. * We should call mipi_dsi_host_register(&host->base) here, but we don't
  156. * have a host->dev, and we don't have OF stuff either. So just use the
  157. * dsi framework as a library and hope for the best. Create the dsi
  158. * devices by ourselves here too. Need to be careful though, because we
  159. * don't initialize any of the driver model devices here.
  160. */
  161. device = kzalloc(sizeof(*device), GFP_KERNEL);
  162. if (!device) {
  163. kfree(host);
  164. return NULL;
  165. }
  166. device->host = &host->base;
  167. host->device = device;
  168. return host;
  169. }
  170. /*
  171. * send a video mode command
  172. *
  173. * XXX: commands with data in MIPI_DPI_DATA?
  174. */
  175. static int dpi_send_cmd(struct intel_dsi *intel_dsi, u32 cmd, bool hs,
  176. enum port port)
  177. {
  178. struct drm_encoder *encoder = &intel_dsi->base.base;
  179. struct drm_device *dev = encoder->dev;
  180. struct drm_i915_private *dev_priv = dev->dev_private;
  181. u32 mask;
  182. /* XXX: pipe, hs */
  183. if (hs)
  184. cmd &= ~DPI_LP_MODE;
  185. else
  186. cmd |= DPI_LP_MODE;
  187. /* clear bit */
  188. I915_WRITE(MIPI_INTR_STAT(port), SPL_PKT_SENT_INTERRUPT);
  189. /* XXX: old code skips write if control unchanged */
  190. if (cmd == I915_READ(MIPI_DPI_CONTROL(port)))
  191. DRM_ERROR("Same special packet %02x twice in a row.\n", cmd);
  192. I915_WRITE(MIPI_DPI_CONTROL(port), cmd);
  193. mask = SPL_PKT_SENT_INTERRUPT;
  194. if (wait_for((I915_READ(MIPI_INTR_STAT(port)) & mask) == mask, 100))
  195. DRM_ERROR("Video mode command 0x%08x send failed.\n", cmd);
  196. return 0;
  197. }
  198. static void band_gap_reset(struct drm_i915_private *dev_priv)
  199. {
  200. mutex_lock(&dev_priv->dpio_lock);
  201. vlv_flisdsi_write(dev_priv, 0x08, 0x0001);
  202. vlv_flisdsi_write(dev_priv, 0x0F, 0x0005);
  203. vlv_flisdsi_write(dev_priv, 0x0F, 0x0025);
  204. udelay(150);
  205. vlv_flisdsi_write(dev_priv, 0x0F, 0x0000);
  206. vlv_flisdsi_write(dev_priv, 0x08, 0x0000);
  207. mutex_unlock(&dev_priv->dpio_lock);
  208. }
  209. static inline bool is_vid_mode(struct intel_dsi *intel_dsi)
  210. {
  211. return intel_dsi->operation_mode == INTEL_DSI_VIDEO_MODE;
  212. }
  213. static inline bool is_cmd_mode(struct intel_dsi *intel_dsi)
  214. {
  215. return intel_dsi->operation_mode == INTEL_DSI_COMMAND_MODE;
  216. }
  217. static void intel_dsi_hot_plug(struct intel_encoder *encoder)
  218. {
  219. DRM_DEBUG_KMS("\n");
  220. }
  221. static bool intel_dsi_compute_config(struct intel_encoder *encoder,
  222. struct intel_crtc_state *config)
  223. {
  224. struct intel_dsi *intel_dsi = container_of(encoder, struct intel_dsi,
  225. base);
  226. struct intel_connector *intel_connector = intel_dsi->attached_connector;
  227. struct drm_display_mode *fixed_mode = intel_connector->panel.fixed_mode;
  228. struct drm_display_mode *adjusted_mode = &config->base.adjusted_mode;
  229. DRM_DEBUG_KMS("\n");
  230. if (fixed_mode)
  231. intel_fixed_panel_mode(fixed_mode, adjusted_mode);
  232. /* DSI uses short packets for sync events, so clear mode flags for DSI */
  233. adjusted_mode->flags = 0;
  234. return true;
  235. }
  236. static void intel_dsi_port_enable(struct intel_encoder *encoder)
  237. {
  238. struct drm_device *dev = encoder->base.dev;
  239. struct drm_i915_private *dev_priv = dev->dev_private;
  240. struct intel_crtc *intel_crtc = to_intel_crtc(encoder->base.crtc);
  241. struct intel_dsi *intel_dsi = enc_to_intel_dsi(&encoder->base);
  242. enum port port;
  243. u32 temp;
  244. if (intel_dsi->dual_link == DSI_DUAL_LINK_FRONT_BACK) {
  245. temp = I915_READ(VLV_CHICKEN_3);
  246. temp &= ~PIXEL_OVERLAP_CNT_MASK |
  247. intel_dsi->pixel_overlap <<
  248. PIXEL_OVERLAP_CNT_SHIFT;
  249. I915_WRITE(VLV_CHICKEN_3, temp);
  250. }
  251. for_each_dsi_port(port, intel_dsi->ports) {
  252. temp = I915_READ(MIPI_PORT_CTRL(port));
  253. temp &= ~LANE_CONFIGURATION_MASK;
  254. temp &= ~DUAL_LINK_MODE_MASK;
  255. if (intel_dsi->ports == ((1 << PORT_A) | (1 << PORT_C))) {
  256. temp |= (intel_dsi->dual_link - 1)
  257. << DUAL_LINK_MODE_SHIFT;
  258. temp |= intel_crtc->pipe ?
  259. LANE_CONFIGURATION_DUAL_LINK_B :
  260. LANE_CONFIGURATION_DUAL_LINK_A;
  261. }
  262. /* assert ip_tg_enable signal */
  263. I915_WRITE(MIPI_PORT_CTRL(port), temp | DPI_ENABLE);
  264. POSTING_READ(MIPI_PORT_CTRL(port));
  265. }
  266. }
  267. static void intel_dsi_port_disable(struct intel_encoder *encoder)
  268. {
  269. struct drm_device *dev = encoder->base.dev;
  270. struct drm_i915_private *dev_priv = dev->dev_private;
  271. struct intel_dsi *intel_dsi = enc_to_intel_dsi(&encoder->base);
  272. enum port port;
  273. u32 temp;
  274. for_each_dsi_port(port, intel_dsi->ports) {
  275. /* de-assert ip_tg_enable signal */
  276. temp = I915_READ(MIPI_PORT_CTRL(port));
  277. I915_WRITE(MIPI_PORT_CTRL(port), temp & ~DPI_ENABLE);
  278. POSTING_READ(MIPI_PORT_CTRL(port));
  279. }
  280. }
  281. static void intel_dsi_device_ready(struct intel_encoder *encoder)
  282. {
  283. struct drm_i915_private *dev_priv = encoder->base.dev->dev_private;
  284. struct intel_dsi *intel_dsi = enc_to_intel_dsi(&encoder->base);
  285. enum port port;
  286. u32 val;
  287. DRM_DEBUG_KMS("\n");
  288. mutex_lock(&dev_priv->dpio_lock);
  289. /* program rcomp for compliance, reduce from 50 ohms to 45 ohms
  290. * needed everytime after power gate */
  291. vlv_flisdsi_write(dev_priv, 0x04, 0x0004);
  292. mutex_unlock(&dev_priv->dpio_lock);
  293. /* bandgap reset is needed after everytime we do power gate */
  294. band_gap_reset(dev_priv);
  295. for_each_dsi_port(port, intel_dsi->ports) {
  296. I915_WRITE(MIPI_DEVICE_READY(port), ULPS_STATE_ENTER);
  297. usleep_range(2500, 3000);
  298. /* Enable MIPI PHY transparent latch
  299. * Common bit for both MIPI Port A & MIPI Port C
  300. * No similar bit in MIPI Port C reg
  301. */
  302. val = I915_READ(MIPI_PORT_CTRL(PORT_A));
  303. I915_WRITE(MIPI_PORT_CTRL(PORT_A), val | LP_OUTPUT_HOLD);
  304. usleep_range(1000, 1500);
  305. I915_WRITE(MIPI_DEVICE_READY(port), ULPS_STATE_EXIT);
  306. usleep_range(2500, 3000);
  307. I915_WRITE(MIPI_DEVICE_READY(port), DEVICE_READY);
  308. usleep_range(2500, 3000);
  309. }
  310. }
  311. static void intel_dsi_enable(struct intel_encoder *encoder)
  312. {
  313. struct drm_device *dev = encoder->base.dev;
  314. struct drm_i915_private *dev_priv = dev->dev_private;
  315. struct intel_dsi *intel_dsi = enc_to_intel_dsi(&encoder->base);
  316. enum port port;
  317. DRM_DEBUG_KMS("\n");
  318. if (is_cmd_mode(intel_dsi)) {
  319. for_each_dsi_port(port, intel_dsi->ports)
  320. I915_WRITE(MIPI_MAX_RETURN_PKT_SIZE(port), 8 * 4);
  321. } else {
  322. msleep(20); /* XXX */
  323. for_each_dsi_port(port, intel_dsi->ports)
  324. dpi_send_cmd(intel_dsi, TURN_ON, false, port);
  325. msleep(100);
  326. drm_panel_enable(intel_dsi->panel);
  327. for_each_dsi_port(port, intel_dsi->ports)
  328. wait_for_dsi_fifo_empty(intel_dsi, port);
  329. intel_dsi_port_enable(encoder);
  330. }
  331. }
  332. static void intel_dsi_pre_enable(struct intel_encoder *encoder)
  333. {
  334. struct drm_device *dev = encoder->base.dev;
  335. struct drm_i915_private *dev_priv = dev->dev_private;
  336. struct intel_dsi *intel_dsi = enc_to_intel_dsi(&encoder->base);
  337. struct intel_crtc *intel_crtc = to_intel_crtc(encoder->base.crtc);
  338. enum pipe pipe = intel_crtc->pipe;
  339. enum port port;
  340. u32 tmp;
  341. DRM_DEBUG_KMS("\n");
  342. /* Disable DPOunit clock gating, can stall pipe
  343. * and we need DPLL REFA always enabled */
  344. tmp = I915_READ(DPLL(pipe));
  345. tmp |= DPLL_REFA_CLK_ENABLE_VLV;
  346. I915_WRITE(DPLL(pipe), tmp);
  347. /* update the hw state for DPLL */
  348. intel_crtc->config->dpll_hw_state.dpll = DPLL_INTEGRATED_CLOCK_VLV |
  349. DPLL_REFA_CLK_ENABLE_VLV;
  350. tmp = I915_READ(DSPCLK_GATE_D);
  351. tmp |= DPOUNIT_CLOCK_GATE_DISABLE;
  352. I915_WRITE(DSPCLK_GATE_D, tmp);
  353. /* put device in ready state */
  354. intel_dsi_device_ready(encoder);
  355. msleep(intel_dsi->panel_on_delay);
  356. drm_panel_prepare(intel_dsi->panel);
  357. for_each_dsi_port(port, intel_dsi->ports)
  358. wait_for_dsi_fifo_empty(intel_dsi, port);
  359. /* Enable port in pre-enable phase itself because as per hw team
  360. * recommendation, port should be enabled befor plane & pipe */
  361. intel_dsi_enable(encoder);
  362. }
  363. static void intel_dsi_enable_nop(struct intel_encoder *encoder)
  364. {
  365. DRM_DEBUG_KMS("\n");
  366. /* for DSI port enable has to be done before pipe
  367. * and plane enable, so port enable is done in
  368. * pre_enable phase itself unlike other encoders
  369. */
  370. }
  371. static void intel_dsi_pre_disable(struct intel_encoder *encoder)
  372. {
  373. struct intel_dsi *intel_dsi = enc_to_intel_dsi(&encoder->base);
  374. enum port port;
  375. DRM_DEBUG_KMS("\n");
  376. if (is_vid_mode(intel_dsi)) {
  377. /* Send Shutdown command to the panel in LP mode */
  378. for_each_dsi_port(port, intel_dsi->ports)
  379. dpi_send_cmd(intel_dsi, SHUTDOWN, false, port);
  380. msleep(10);
  381. }
  382. }
  383. static void intel_dsi_disable(struct intel_encoder *encoder)
  384. {
  385. struct drm_device *dev = encoder->base.dev;
  386. struct drm_i915_private *dev_priv = dev->dev_private;
  387. struct intel_dsi *intel_dsi = enc_to_intel_dsi(&encoder->base);
  388. enum port port;
  389. u32 temp;
  390. DRM_DEBUG_KMS("\n");
  391. if (is_vid_mode(intel_dsi)) {
  392. for_each_dsi_port(port, intel_dsi->ports)
  393. wait_for_dsi_fifo_empty(intel_dsi, port);
  394. intel_dsi_port_disable(encoder);
  395. msleep(2);
  396. }
  397. for_each_dsi_port(port, intel_dsi->ports) {
  398. /* Panel commands can be sent when clock is in LP11 */
  399. I915_WRITE(MIPI_DEVICE_READY(port), 0x0);
  400. temp = I915_READ(MIPI_CTRL(port));
  401. temp &= ~ESCAPE_CLOCK_DIVIDER_MASK;
  402. I915_WRITE(MIPI_CTRL(port), temp |
  403. intel_dsi->escape_clk_div <<
  404. ESCAPE_CLOCK_DIVIDER_SHIFT);
  405. I915_WRITE(MIPI_EOT_DISABLE(port), CLOCKSTOP);
  406. temp = I915_READ(MIPI_DSI_FUNC_PRG(port));
  407. temp &= ~VID_MODE_FORMAT_MASK;
  408. I915_WRITE(MIPI_DSI_FUNC_PRG(port), temp);
  409. I915_WRITE(MIPI_DEVICE_READY(port), 0x1);
  410. }
  411. /* if disable packets are sent before sending shutdown packet then in
  412. * some next enable sequence send turn on packet error is observed */
  413. drm_panel_disable(intel_dsi->panel);
  414. for_each_dsi_port(port, intel_dsi->ports)
  415. wait_for_dsi_fifo_empty(intel_dsi, port);
  416. }
  417. static void intel_dsi_clear_device_ready(struct intel_encoder *encoder)
  418. {
  419. struct drm_i915_private *dev_priv = encoder->base.dev->dev_private;
  420. struct intel_dsi *intel_dsi = enc_to_intel_dsi(&encoder->base);
  421. enum port port;
  422. u32 val;
  423. DRM_DEBUG_KMS("\n");
  424. for_each_dsi_port(port, intel_dsi->ports) {
  425. I915_WRITE(MIPI_DEVICE_READY(port), DEVICE_READY |
  426. ULPS_STATE_ENTER);
  427. usleep_range(2000, 2500);
  428. I915_WRITE(MIPI_DEVICE_READY(port), DEVICE_READY |
  429. ULPS_STATE_EXIT);
  430. usleep_range(2000, 2500);
  431. I915_WRITE(MIPI_DEVICE_READY(port), DEVICE_READY |
  432. ULPS_STATE_ENTER);
  433. usleep_range(2000, 2500);
  434. /* Wait till Clock lanes are in LP-00 state for MIPI Port A
  435. * only. MIPI Port C has no similar bit for checking
  436. */
  437. if (wait_for(((I915_READ(MIPI_PORT_CTRL(PORT_A)) & AFE_LATCHOUT)
  438. == 0x00000), 30))
  439. DRM_ERROR("DSI LP not going Low\n");
  440. /* Disable MIPI PHY transparent latch
  441. * Common bit for both MIPI Port A & MIPI Port C
  442. */
  443. val = I915_READ(MIPI_PORT_CTRL(PORT_A));
  444. I915_WRITE(MIPI_PORT_CTRL(PORT_A), val & ~LP_OUTPUT_HOLD);
  445. usleep_range(1000, 1500);
  446. I915_WRITE(MIPI_DEVICE_READY(port), 0x00);
  447. usleep_range(2000, 2500);
  448. }
  449. vlv_disable_dsi_pll(encoder);
  450. }
  451. static void intel_dsi_post_disable(struct intel_encoder *encoder)
  452. {
  453. struct drm_i915_private *dev_priv = encoder->base.dev->dev_private;
  454. struct intel_dsi *intel_dsi = enc_to_intel_dsi(&encoder->base);
  455. u32 val;
  456. DRM_DEBUG_KMS("\n");
  457. intel_dsi_disable(encoder);
  458. intel_dsi_clear_device_ready(encoder);
  459. val = I915_READ(DSPCLK_GATE_D);
  460. val &= ~DPOUNIT_CLOCK_GATE_DISABLE;
  461. I915_WRITE(DSPCLK_GATE_D, val);
  462. drm_panel_unprepare(intel_dsi->panel);
  463. msleep(intel_dsi->panel_off_delay);
  464. msleep(intel_dsi->panel_pwr_cycle_delay);
  465. }
  466. static bool intel_dsi_get_hw_state(struct intel_encoder *encoder,
  467. enum pipe *pipe)
  468. {
  469. struct drm_i915_private *dev_priv = encoder->base.dev->dev_private;
  470. struct intel_dsi *intel_dsi = enc_to_intel_dsi(&encoder->base);
  471. struct drm_device *dev = encoder->base.dev;
  472. enum intel_display_power_domain power_domain;
  473. u32 dpi_enabled, func;
  474. enum port port;
  475. DRM_DEBUG_KMS("\n");
  476. power_domain = intel_display_port_power_domain(encoder);
  477. if (!intel_display_power_is_enabled(dev_priv, power_domain))
  478. return false;
  479. /* XXX: this only works for one DSI output */
  480. for_each_dsi_port(port, intel_dsi->ports) {
  481. func = I915_READ(MIPI_DSI_FUNC_PRG(port));
  482. dpi_enabled = I915_READ(MIPI_PORT_CTRL(port)) &
  483. DPI_ENABLE;
  484. /* Due to some hardware limitations on BYT, MIPI Port C DPI
  485. * Enable bit does not get set. To check whether DSI Port C
  486. * was enabled in BIOS, check the Pipe B enable bit
  487. */
  488. if (IS_VALLEYVIEW(dev) && !IS_CHERRYVIEW(dev) &&
  489. (port == PORT_C))
  490. dpi_enabled = I915_READ(PIPECONF(PIPE_B)) &
  491. PIPECONF_ENABLE;
  492. if (dpi_enabled || (func & CMD_MODE_DATA_WIDTH_MASK)) {
  493. if (I915_READ(MIPI_DEVICE_READY(port)) & DEVICE_READY) {
  494. *pipe = port == PORT_A ? PIPE_A : PIPE_B;
  495. return true;
  496. }
  497. }
  498. }
  499. return false;
  500. }
  501. static void intel_dsi_get_config(struct intel_encoder *encoder,
  502. struct intel_crtc_state *pipe_config)
  503. {
  504. u32 pclk;
  505. DRM_DEBUG_KMS("\n");
  506. /*
  507. * DPLL_MD is not used in case of DSI, reading will get some default value
  508. * set dpll_md = 0
  509. */
  510. pipe_config->dpll_hw_state.dpll_md = 0;
  511. pclk = vlv_get_dsi_pclk(encoder, pipe_config->pipe_bpp);
  512. if (!pclk)
  513. return;
  514. pipe_config->base.adjusted_mode.crtc_clock = pclk;
  515. pipe_config->port_clock = pclk;
  516. }
  517. static enum drm_mode_status
  518. intel_dsi_mode_valid(struct drm_connector *connector,
  519. struct drm_display_mode *mode)
  520. {
  521. struct intel_connector *intel_connector = to_intel_connector(connector);
  522. struct drm_display_mode *fixed_mode = intel_connector->panel.fixed_mode;
  523. DRM_DEBUG_KMS("\n");
  524. if (mode->flags & DRM_MODE_FLAG_DBLSCAN) {
  525. DRM_DEBUG_KMS("MODE_NO_DBLESCAN\n");
  526. return MODE_NO_DBLESCAN;
  527. }
  528. if (fixed_mode) {
  529. if (mode->hdisplay > fixed_mode->hdisplay)
  530. return MODE_PANEL;
  531. if (mode->vdisplay > fixed_mode->vdisplay)
  532. return MODE_PANEL;
  533. }
  534. return MODE_OK;
  535. }
  536. /* return txclkesc cycles in terms of divider and duration in us */
  537. static u16 txclkesc(u32 divider, unsigned int us)
  538. {
  539. switch (divider) {
  540. case ESCAPE_CLOCK_DIVIDER_1:
  541. default:
  542. return 20 * us;
  543. case ESCAPE_CLOCK_DIVIDER_2:
  544. return 10 * us;
  545. case ESCAPE_CLOCK_DIVIDER_4:
  546. return 5 * us;
  547. }
  548. }
  549. /* return pixels in terms of txbyteclkhs */
  550. static u16 txbyteclkhs(u16 pixels, int bpp, int lane_count,
  551. u16 burst_mode_ratio)
  552. {
  553. return DIV_ROUND_UP(DIV_ROUND_UP(pixels * bpp * burst_mode_ratio,
  554. 8 * 100), lane_count);
  555. }
  556. static void set_dsi_timings(struct drm_encoder *encoder,
  557. const struct drm_display_mode *mode)
  558. {
  559. struct drm_device *dev = encoder->dev;
  560. struct drm_i915_private *dev_priv = dev->dev_private;
  561. struct intel_crtc *intel_crtc = to_intel_crtc(encoder->crtc);
  562. struct intel_dsi *intel_dsi = enc_to_intel_dsi(encoder);
  563. enum port port;
  564. unsigned int bpp = intel_crtc->config->pipe_bpp;
  565. unsigned int lane_count = intel_dsi->lane_count;
  566. u16 hactive, hfp, hsync, hbp, vfp, vsync, vbp;
  567. hactive = mode->hdisplay;
  568. hfp = mode->hsync_start - mode->hdisplay;
  569. hsync = mode->hsync_end - mode->hsync_start;
  570. hbp = mode->htotal - mode->hsync_end;
  571. if (intel_dsi->dual_link) {
  572. hactive /= 2;
  573. if (intel_dsi->dual_link == DSI_DUAL_LINK_FRONT_BACK)
  574. hactive += intel_dsi->pixel_overlap;
  575. hfp /= 2;
  576. hsync /= 2;
  577. hbp /= 2;
  578. }
  579. vfp = mode->vsync_start - mode->vdisplay;
  580. vsync = mode->vsync_end - mode->vsync_start;
  581. vbp = mode->vtotal - mode->vsync_end;
  582. /* horizontal values are in terms of high speed byte clock */
  583. hactive = txbyteclkhs(hactive, bpp, lane_count,
  584. intel_dsi->burst_mode_ratio);
  585. hfp = txbyteclkhs(hfp, bpp, lane_count, intel_dsi->burst_mode_ratio);
  586. hsync = txbyteclkhs(hsync, bpp, lane_count,
  587. intel_dsi->burst_mode_ratio);
  588. hbp = txbyteclkhs(hbp, bpp, lane_count, intel_dsi->burst_mode_ratio);
  589. for_each_dsi_port(port, intel_dsi->ports) {
  590. I915_WRITE(MIPI_HACTIVE_AREA_COUNT(port), hactive);
  591. I915_WRITE(MIPI_HFP_COUNT(port), hfp);
  592. /* meaningful for video mode non-burst sync pulse mode only,
  593. * can be zero for non-burst sync events and burst modes */
  594. I915_WRITE(MIPI_HSYNC_PADDING_COUNT(port), hsync);
  595. I915_WRITE(MIPI_HBP_COUNT(port), hbp);
  596. /* vertical values are in terms of lines */
  597. I915_WRITE(MIPI_VFP_COUNT(port), vfp);
  598. I915_WRITE(MIPI_VSYNC_PADDING_COUNT(port), vsync);
  599. I915_WRITE(MIPI_VBP_COUNT(port), vbp);
  600. }
  601. }
  602. static void intel_dsi_prepare(struct intel_encoder *intel_encoder)
  603. {
  604. struct drm_encoder *encoder = &intel_encoder->base;
  605. struct drm_device *dev = encoder->dev;
  606. struct drm_i915_private *dev_priv = dev->dev_private;
  607. struct intel_crtc *intel_crtc = to_intel_crtc(encoder->crtc);
  608. struct intel_dsi *intel_dsi = enc_to_intel_dsi(encoder);
  609. struct drm_display_mode *adjusted_mode =
  610. &intel_crtc->config->base.adjusted_mode;
  611. enum port port;
  612. unsigned int bpp = intel_crtc->config->pipe_bpp;
  613. u32 val, tmp;
  614. u16 mode_hdisplay;
  615. DRM_DEBUG_KMS("pipe %c\n", pipe_name(intel_crtc->pipe));
  616. mode_hdisplay = adjusted_mode->hdisplay;
  617. if (intel_dsi->dual_link) {
  618. mode_hdisplay /= 2;
  619. if (intel_dsi->dual_link == DSI_DUAL_LINK_FRONT_BACK)
  620. mode_hdisplay += intel_dsi->pixel_overlap;
  621. }
  622. for_each_dsi_port(port, intel_dsi->ports) {
  623. /* escape clock divider, 20MHz, shared for A and C.
  624. * device ready must be off when doing this! txclkesc? */
  625. tmp = I915_READ(MIPI_CTRL(PORT_A));
  626. tmp &= ~ESCAPE_CLOCK_DIVIDER_MASK;
  627. I915_WRITE(MIPI_CTRL(PORT_A), tmp | ESCAPE_CLOCK_DIVIDER_1);
  628. /* read request priority is per pipe */
  629. tmp = I915_READ(MIPI_CTRL(port));
  630. tmp &= ~READ_REQUEST_PRIORITY_MASK;
  631. I915_WRITE(MIPI_CTRL(port), tmp | READ_REQUEST_PRIORITY_HIGH);
  632. /* XXX: why here, why like this? handling in irq handler?! */
  633. I915_WRITE(MIPI_INTR_STAT(port), 0xffffffff);
  634. I915_WRITE(MIPI_INTR_EN(port), 0xffffffff);
  635. I915_WRITE(MIPI_DPHY_PARAM(port), intel_dsi->dphy_reg);
  636. I915_WRITE(MIPI_DPI_RESOLUTION(port),
  637. adjusted_mode->vdisplay << VERTICAL_ADDRESS_SHIFT |
  638. mode_hdisplay << HORIZONTAL_ADDRESS_SHIFT);
  639. }
  640. set_dsi_timings(encoder, adjusted_mode);
  641. val = intel_dsi->lane_count << DATA_LANES_PRG_REG_SHIFT;
  642. if (is_cmd_mode(intel_dsi)) {
  643. val |= intel_dsi->channel << CMD_MODE_CHANNEL_NUMBER_SHIFT;
  644. val |= CMD_MODE_DATA_WIDTH_8_BIT; /* XXX */
  645. } else {
  646. val |= intel_dsi->channel << VID_MODE_CHANNEL_NUMBER_SHIFT;
  647. /* XXX: cross-check bpp vs. pixel format? */
  648. val |= intel_dsi->pixel_format;
  649. }
  650. tmp = 0;
  651. if (intel_dsi->eotp_pkt == 0)
  652. tmp |= EOT_DISABLE;
  653. if (intel_dsi->clock_stop)
  654. tmp |= CLOCKSTOP;
  655. for_each_dsi_port(port, intel_dsi->ports) {
  656. I915_WRITE(MIPI_DSI_FUNC_PRG(port), val);
  657. /* timeouts for recovery. one frame IIUC. if counter expires,
  658. * EOT and stop state. */
  659. /*
  660. * In burst mode, value greater than one DPI line Time in byte
  661. * clock (txbyteclkhs) To timeout this timer 1+ of the above
  662. * said value is recommended.
  663. *
  664. * In non-burst mode, Value greater than one DPI frame time in
  665. * byte clock(txbyteclkhs) To timeout this timer 1+ of the above
  666. * said value is recommended.
  667. *
  668. * In DBI only mode, value greater than one DBI frame time in
  669. * byte clock(txbyteclkhs) To timeout this timer 1+ of the above
  670. * said value is recommended.
  671. */
  672. if (is_vid_mode(intel_dsi) &&
  673. intel_dsi->video_mode_format == VIDEO_MODE_BURST) {
  674. I915_WRITE(MIPI_HS_TX_TIMEOUT(port),
  675. txbyteclkhs(adjusted_mode->htotal, bpp,
  676. intel_dsi->lane_count,
  677. intel_dsi->burst_mode_ratio) + 1);
  678. } else {
  679. I915_WRITE(MIPI_HS_TX_TIMEOUT(port),
  680. txbyteclkhs(adjusted_mode->vtotal *
  681. adjusted_mode->htotal,
  682. bpp, intel_dsi->lane_count,
  683. intel_dsi->burst_mode_ratio) + 1);
  684. }
  685. I915_WRITE(MIPI_LP_RX_TIMEOUT(port), intel_dsi->lp_rx_timeout);
  686. I915_WRITE(MIPI_TURN_AROUND_TIMEOUT(port),
  687. intel_dsi->turn_arnd_val);
  688. I915_WRITE(MIPI_DEVICE_RESET_TIMER(port),
  689. intel_dsi->rst_timer_val);
  690. /* dphy stuff */
  691. /* in terms of low power clock */
  692. I915_WRITE(MIPI_INIT_COUNT(port),
  693. txclkesc(intel_dsi->escape_clk_div, 100));
  694. /* recovery disables */
  695. I915_WRITE(MIPI_EOT_DISABLE(port), tmp);
  696. /* in terms of low power clock */
  697. I915_WRITE(MIPI_INIT_COUNT(port), intel_dsi->init_count);
  698. /* in terms of txbyteclkhs. actual high to low switch +
  699. * MIPI_STOP_STATE_STALL * MIPI_LP_BYTECLK.
  700. *
  701. * XXX: write MIPI_STOP_STATE_STALL?
  702. */
  703. I915_WRITE(MIPI_HIGH_LOW_SWITCH_COUNT(port),
  704. intel_dsi->hs_to_lp_count);
  705. /* XXX: low power clock equivalence in terms of byte clock.
  706. * the number of byte clocks occupied in one low power clock.
  707. * based on txbyteclkhs and txclkesc.
  708. * txclkesc time / txbyteclk time * (105 + MIPI_STOP_STATE_STALL
  709. * ) / 105.???
  710. */
  711. I915_WRITE(MIPI_LP_BYTECLK(port), intel_dsi->lp_byte_clk);
  712. /* the bw essential for transmitting 16 long packets containing
  713. * 252 bytes meant for dcs write memory command is programmed in
  714. * this register in terms of byte clocks. based on dsi transfer
  715. * rate and the number of lanes configured the time taken to
  716. * transmit 16 long packets in a dsi stream varies. */
  717. I915_WRITE(MIPI_DBI_BW_CTRL(port), intel_dsi->bw_timer);
  718. I915_WRITE(MIPI_CLK_LANE_SWITCH_TIME_CNT(port),
  719. intel_dsi->clk_lp_to_hs_count << LP_HS_SSW_CNT_SHIFT |
  720. intel_dsi->clk_hs_to_lp_count << HS_LP_PWR_SW_CNT_SHIFT);
  721. if (is_vid_mode(intel_dsi))
  722. /* Some panels might have resolution which is not a
  723. * multiple of 64 like 1366 x 768. Enable RANDOM
  724. * resolution support for such panels by default */
  725. I915_WRITE(MIPI_VIDEO_MODE_FORMAT(port),
  726. intel_dsi->video_frmt_cfg_bits |
  727. intel_dsi->video_mode_format |
  728. IP_TG_CONFIG |
  729. RANDOM_DPI_DISPLAY_RESOLUTION);
  730. }
  731. }
  732. static void intel_dsi_pre_pll_enable(struct intel_encoder *encoder)
  733. {
  734. DRM_DEBUG_KMS("\n");
  735. intel_dsi_prepare(encoder);
  736. vlv_enable_dsi_pll(encoder);
  737. }
  738. static enum drm_connector_status
  739. intel_dsi_detect(struct drm_connector *connector, bool force)
  740. {
  741. return connector_status_connected;
  742. }
  743. static int intel_dsi_get_modes(struct drm_connector *connector)
  744. {
  745. struct intel_connector *intel_connector = to_intel_connector(connector);
  746. struct drm_display_mode *mode;
  747. DRM_DEBUG_KMS("\n");
  748. if (!intel_connector->panel.fixed_mode) {
  749. DRM_DEBUG_KMS("no fixed mode\n");
  750. return 0;
  751. }
  752. mode = drm_mode_duplicate(connector->dev,
  753. intel_connector->panel.fixed_mode);
  754. if (!mode) {
  755. DRM_DEBUG_KMS("drm_mode_duplicate failed\n");
  756. return 0;
  757. }
  758. drm_mode_probed_add(connector, mode);
  759. return 1;
  760. }
  761. static void intel_dsi_connector_destroy(struct drm_connector *connector)
  762. {
  763. struct intel_connector *intel_connector = to_intel_connector(connector);
  764. DRM_DEBUG_KMS("\n");
  765. intel_panel_fini(&intel_connector->panel);
  766. drm_connector_cleanup(connector);
  767. kfree(connector);
  768. }
  769. static void intel_dsi_encoder_destroy(struct drm_encoder *encoder)
  770. {
  771. struct intel_dsi *intel_dsi = enc_to_intel_dsi(encoder);
  772. if (intel_dsi->panel) {
  773. drm_panel_detach(intel_dsi->panel);
  774. /* XXX: Logically this call belongs in the panel driver. */
  775. drm_panel_remove(intel_dsi->panel);
  776. }
  777. intel_encoder_destroy(encoder);
  778. }
  779. static const struct drm_encoder_funcs intel_dsi_funcs = {
  780. .destroy = intel_dsi_encoder_destroy,
  781. };
  782. static const struct drm_connector_helper_funcs intel_dsi_connector_helper_funcs = {
  783. .get_modes = intel_dsi_get_modes,
  784. .mode_valid = intel_dsi_mode_valid,
  785. .best_encoder = intel_best_encoder,
  786. };
  787. static const struct drm_connector_funcs intel_dsi_connector_funcs = {
  788. .dpms = intel_connector_dpms,
  789. .detect = intel_dsi_detect,
  790. .destroy = intel_dsi_connector_destroy,
  791. .fill_modes = drm_helper_probe_single_connector_modes,
  792. .atomic_get_property = intel_connector_atomic_get_property,
  793. .atomic_destroy_state = drm_atomic_helper_connector_destroy_state,
  794. .atomic_duplicate_state = drm_atomic_helper_connector_duplicate_state,
  795. };
  796. void intel_dsi_init(struct drm_device *dev)
  797. {
  798. struct intel_dsi *intel_dsi;
  799. struct intel_encoder *intel_encoder;
  800. struct drm_encoder *encoder;
  801. struct intel_connector *intel_connector;
  802. struct drm_connector *connector;
  803. struct drm_display_mode *scan, *fixed_mode = NULL;
  804. struct drm_i915_private *dev_priv = dev->dev_private;
  805. enum port port;
  806. unsigned int i;
  807. DRM_DEBUG_KMS("\n");
  808. /* There is no detection method for MIPI so rely on VBT */
  809. if (!dev_priv->vbt.has_mipi)
  810. return;
  811. if (IS_VALLEYVIEW(dev)) {
  812. dev_priv->mipi_mmio_base = VLV_MIPI_BASE;
  813. } else {
  814. DRM_ERROR("Unsupported Mipi device to reg base");
  815. return;
  816. }
  817. intel_dsi = kzalloc(sizeof(*intel_dsi), GFP_KERNEL);
  818. if (!intel_dsi)
  819. return;
  820. intel_connector = intel_connector_alloc();
  821. if (!intel_connector) {
  822. kfree(intel_dsi);
  823. return;
  824. }
  825. intel_encoder = &intel_dsi->base;
  826. encoder = &intel_encoder->base;
  827. intel_dsi->attached_connector = intel_connector;
  828. connector = &intel_connector->base;
  829. drm_encoder_init(dev, encoder, &intel_dsi_funcs, DRM_MODE_ENCODER_DSI);
  830. /* XXX: very likely not all of these are needed */
  831. intel_encoder->hot_plug = intel_dsi_hot_plug;
  832. intel_encoder->compute_config = intel_dsi_compute_config;
  833. intel_encoder->pre_pll_enable = intel_dsi_pre_pll_enable;
  834. intel_encoder->pre_enable = intel_dsi_pre_enable;
  835. intel_encoder->enable = intel_dsi_enable_nop;
  836. intel_encoder->disable = intel_dsi_pre_disable;
  837. intel_encoder->post_disable = intel_dsi_post_disable;
  838. intel_encoder->get_hw_state = intel_dsi_get_hw_state;
  839. intel_encoder->get_config = intel_dsi_get_config;
  840. intel_connector->get_hw_state = intel_connector_get_hw_state;
  841. intel_connector->unregister = intel_connector_unregister;
  842. /* Pipe A maps to MIPI DSI port A, pipe B maps to MIPI DSI port C */
  843. if (dev_priv->vbt.dsi.config->dual_link) {
  844. /* XXX: does dual link work on either pipe? */
  845. intel_encoder->crtc_mask = (1 << PIPE_A);
  846. intel_dsi->ports = ((1 << PORT_A) | (1 << PORT_C));
  847. } else if (dev_priv->vbt.dsi.port == DVO_PORT_MIPIA) {
  848. intel_encoder->crtc_mask = (1 << PIPE_A);
  849. intel_dsi->ports = (1 << PORT_A);
  850. } else if (dev_priv->vbt.dsi.port == DVO_PORT_MIPIC) {
  851. intel_encoder->crtc_mask = (1 << PIPE_B);
  852. intel_dsi->ports = (1 << PORT_C);
  853. }
  854. /* Create a DSI host (and a device) for each port. */
  855. for_each_dsi_port(port, intel_dsi->ports) {
  856. struct intel_dsi_host *host;
  857. host = intel_dsi_host_init(intel_dsi, port);
  858. if (!host)
  859. goto err;
  860. intel_dsi->dsi_hosts[port] = host;
  861. }
  862. for (i = 0; i < ARRAY_SIZE(intel_dsi_drivers); i++) {
  863. intel_dsi->panel = intel_dsi_drivers[i].init(intel_dsi,
  864. intel_dsi_drivers[i].panel_id);
  865. if (intel_dsi->panel)
  866. break;
  867. }
  868. if (!intel_dsi->panel) {
  869. DRM_DEBUG_KMS("no device found\n");
  870. goto err;
  871. }
  872. intel_encoder->type = INTEL_OUTPUT_DSI;
  873. intel_encoder->cloneable = 0;
  874. drm_connector_init(dev, connector, &intel_dsi_connector_funcs,
  875. DRM_MODE_CONNECTOR_DSI);
  876. drm_connector_helper_add(connector, &intel_dsi_connector_helper_funcs);
  877. connector->display_info.subpixel_order = SubPixelHorizontalRGB; /*XXX*/
  878. connector->interlace_allowed = false;
  879. connector->doublescan_allowed = false;
  880. intel_connector_attach_encoder(intel_connector, intel_encoder);
  881. drm_connector_register(connector);
  882. drm_panel_attach(intel_dsi->panel, connector);
  883. mutex_lock(&dev->mode_config.mutex);
  884. drm_panel_get_modes(intel_dsi->panel);
  885. list_for_each_entry(scan, &connector->probed_modes, head) {
  886. if ((scan->type & DRM_MODE_TYPE_PREFERRED)) {
  887. fixed_mode = drm_mode_duplicate(dev, scan);
  888. break;
  889. }
  890. }
  891. mutex_unlock(&dev->mode_config.mutex);
  892. if (!fixed_mode) {
  893. DRM_DEBUG_KMS("no fixed mode\n");
  894. goto err;
  895. }
  896. intel_panel_init(&intel_connector->panel, fixed_mode, NULL);
  897. return;
  898. err:
  899. drm_encoder_cleanup(&intel_encoder->base);
  900. kfree(intel_dsi);
  901. kfree(intel_connector);
  902. }